1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.eclipse.adt.internal.editors.layout.gle2; 18 19 import org.eclipse.swt.graphics.Device; 20 import org.eclipse.swt.graphics.GC; 21 22 /** 23 * An Overlay is a set of graphics which can be painted on top of the visual 24 * editor. Different {@link Gesture}s produce context specific overlays, such as 25 * swiping rectangles from the {@link MarqueeGesture} and guidelines from the 26 * {@link MoveGesture}. 27 */ 28 public abstract class Overlay { 29 private Device mDevice; 30 31 /** Whether the hover is hidden */ 32 private boolean mHiding; 33 34 /** 35 * Construct the overlay, using the given graphics context for painting. 36 */ 37 public Overlay() { 38 super(); 39 } 40 41 /** 42 * Initializes the overlay before the first use, if applicable. This is a 43 * good place to initialize resources like colors. 44 * 45 * @param device The device to allocate resources for; the parameter passed 46 * to {@link #paint} will correspond to this device. 47 */ 48 public void create(Device device) { 49 mDevice = device; 50 } 51 52 /** 53 * Releases resources held by the overlay. Called by the editor when an 54 * overlay has been removed. 55 */ 56 public void dispose() { 57 } 58 59 /** 60 * Paints the overlay. 61 * 62 * @param gc The SWT {@link GC} object to draw into. 63 */ 64 public void paint(GC gc) { 65 throw new IllegalArgumentException("paint() not implemented, probably done " 66 + "with specialized paint signature"); 67 } 68 69 /** Returns the device associated with this overlay */ 70 public Device getDevice() { 71 return mDevice; 72 } 73 74 /** 75 * Returns whether the overlay is hidden 76 * 77 * @return true if the selection overlay is hidden 78 */ 79 public boolean isHiding() { 80 return mHiding; 81 } 82 83 /** 84 * Hides the overlay 85 * 86 * @param hiding true to hide the overlay, false to unhide it (default) 87 */ 88 public void setHiding(boolean hiding) { 89 mHiding = hiding; 90 } 91 } 92