1// BEGIN LICENSE BLOCK 2// Version: CMPL 1.1 3// 4// The contents of this file are subject to the Cisco-style Mozilla Public 5// License Version 1.1 (the "License"); you may not use this file except 6// in compliance with the License. You may obtain a copy of the License 7// at www.eclipse-clp.org/license. 8// 9// Software distributed under the License is distributed on an "AS IS" 10// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11// the License for the specific language governing rights and limitations 12// under the License. 13// 14// The Original Code is The ECLiPSe Constraint Logic Programming System. 15// The Initial Developer of the Original Code is Cisco Systems, Inc. 16// Portions created by the Initial Developer are 17// Copyright (C) 2006 Cisco Systems, Inc. All Rights Reserved. 18// 19// Contributor(s): 20// 21// END LICENSE BLOCK 22 23package com.parctechnologies.eclipse.visualisation.viewers; 24 25import java.awt.*; 26import javax.swing.*; 27 28/** 29 * Small Icon to be used for ToggleHold action and to display in corner of 30 * viewlet component. 31 * 32 */ 33public class HoldIcon implements Icon 34{ 35 private int height; 36 private int width; 37 private Rectangle rect1, rect2; 38 private Color holdSymbolColor = new Color(180, 180, 180); 39 40 public HoldIcon(int width, int height) 41 { 42 this.width = width; 43 this.height = height; 44 initialiseShapes(); 45 } 46 47 private void initialiseShapes() 48 { 49 rect1 = 50 new Rectangle((int) (width * 0.1), (int) (height * 0.2), 51 (int) (width * 0.35), (int) (height * 0.6)); 52 53 rect2 = 54 new Rectangle((int) (width * 0.55), (int) (height * 0.2), 55 (int) (width * 0.35), (int) (height * 0.6)); 56 } 57 58 public int getIconHeight() 59 { 60 return(height); 61 } 62 63 public int getIconWidth() 64 { 65 return(width); 66 } 67 68 public void paintIcon(Component c, Graphics g, int x, int y) 69 { 70 g.setColor(holdSymbolColor); 71 g.fillRect(x+rect1.x, y+rect1.y, rect1.width, rect1.height); 72 g.fillRect(x+rect2.x, y+rect2.y, rect2.width, rect2.height); 73 g.setColor(c.getForeground()); 74 g.drawRect(x+rect1.x, y+rect1.y, rect1.width, rect1.height); 75 g.drawRect(x+rect2.x, y+rect2.y, rect2.width, rect2.height); 76 } 77} 78