⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 egraphics.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	 */	public void setForeground(boolean f) { foreground = f; }	/**	 * Method to return the color associated with this EGraphics.	 * @return the color associated with this EGraphics.	 */	public Color getColor()	{		int alpha = (int)(opacity * 255.0);		Color color = new Color(red, green, blue, alpha);		return color;	}	/**	 * Method to return the color associated with this EGraphics with full opacity.	 * @return the color associated with this EGraphics.	 */	public Color getOpaqueColor()	{		Color color = new Color(red, green, blue, 255);		return color;	}	/**	 * Method to get the RGB value representing the color by factory default.	 * (Bits 16-23 are red, 8-15 are green, 0-7 are blue).	 * Alpha/opacity component is not returned.	 * @return the RGB value representing the color by factory default.	 */	public int getFactoryColor()	{		if (layer == null) return 0;		Pref pref = colorMap.get(layer);		return pref.getIntFactoryValue();	}	/**	 * Returns the RGB value representing the color associated with this EGraphics.	 * (Bits 16-23 are red, 8-15 are green, 0-7 are blue).	 * Alpha/opacity component is not returned	 * @return the RGB value of the color	 */	public int getRGB() {		return (red << 16) | (green << 8) | blue;	}	/**	 * Method to set the color associated with this EGraphics.	 * @param color the color to set.	 */	public void setColor(Color color)	{		transparentLayer = 0;		red = color.getRed();		green = color.getGreen();		blue = color.getBlue();		if (layer != null)		{			Pref pref = colorMap.get(layer);			if (pref != null) pref.setInt((red << 16) | (green << 8) | blue);		}		// update any color used in 3D view if available		Object obj3D = get3DAppearance();		if (obj3D != null)		{			Class<?> app3DClass = Resources.get3DClass("utils.J3DAppearance");			try			{				Method setColorMethod3DClass = app3DClass.getDeclaredMethod("set3DColor", new Class[] {Object.class, Color.class});				setColorMethod3DClass.invoke(obj3D, new Object[]{null, color});			} catch (Exception e) {				System.out.println("Cannot call 3D plugin method set3DColor: " + e.getMessage());			}		}	}	/**	 * Method to convert a color index into a Color.	 * Color indices are more general than colors, because they can handle	 * transparent layers, C-Electric-style opaque layers, and full color values.	 * @param colorIndex the color index to convert.	 * @return a Color that describes the index	 * Returns null if the index is a transparent layer.	 */	public static Color getColorFromIndex(int colorIndex)	{		if ((colorIndex&OPAQUEBIT) != 0)		{			// an opaque color			switch (colorIndex)			{				case WHITE:   return new Color(255, 255, 255);				case BLACK:   return new Color(  0,   0,   0);				case RED:     return new Color(255,   0,   0);				case BLUE:    return new Color(  0,   0, 255);				case GREEN:   return new Color(  0, 255,   0);				case CYAN:    return new Color(  0, 255, 255);				case MAGENTA: return new Color(255,   0, 255);				case YELLOW:  return new Color(255, 255,   0);				case CELLTXT: return new Color(  0,   0,   0);				case CELLOUT: return new Color(  0,   0,   0);				case WINBOR:  return new Color(  0,   0,   0);				case HWINBOR: return new Color(  0, 255,   0);				case MENBOR:  return new Color(  0,   0,   0);				case HMENBOR: return new Color(255, 255, 255);				case MENTXT:  return new Color(  0,   0,   0);				case MENGLY:  return new Color(  0,   0,   0);				case CURSOR:  return new Color(  0,   0,   0);				case GRAY:    return new Color(180, 180, 180);				case ORANGE:  return new Color(255, 190,   6);				case PURPLE:  return new Color(186,   0, 255);				case BROWN:   return new Color(139,  99,  46);				case LGRAY:   return new Color(230, 230, 230);				case DGRAY:   return new Color(100, 100, 100);				case LRED:    return new Color(255, 150, 150);				case DRED:    return new Color(159,  80,  80);				case LGREEN:  return new Color(175, 255, 175);				case DGREEN:  return new Color( 89, 159,  85);				case LBLUE:   return new Color(150, 150, 255);				case DBLUE:   return new Color(  2,  15, 159);			}			return null;		}		if ((colorIndex&FULLRGBBIT) != 0)		{			// a full RGB color (opaque)			return new Color((colorIndex >> 24) & 0xFF, (colorIndex >> 16) & 0xFF, (colorIndex >> 8) & 0xFF);		}		// handle transparent colors		Technology curTech = Technology.getCurrent();		Color [] colorMap = curTech.getColorMap();		if (colorMap == null)		{			Technology altTech = Schematics.getDefaultSchematicTechnology();			if (altTech != curTech)			{				colorMap = altTech.getColorMap();			}			if (colorMap == null) return null;		}		int trueIndex = colorIndex >> 2;		if (trueIndex < colorMap.length) return colorMap[trueIndex];		return null;	}	/**	 * Method to set the color of this EGraphics from a "color index".	 * Color indices are more general than colors, because they can handle	 * transparent layers, C-Electric-style opaque layers, and full color values.	 * Artwork nodes and arcs represent individualized color by using color indices.	 * @param colorIndex the color index to set.	 */	public void setColorIndex(int colorIndex)	{		if ((colorIndex&(OPAQUEBIT|FULLRGBBIT)) != 0)		{			// an opaque or full RGB color			transparentLayer = 0;			setColor(getColorFromIndex(colorIndex));			return;		}		// a transparent color		if ((colorIndex&LAYERT1) != 0) transparentLayer = TRANSPARENT_1; else		if ((colorIndex&LAYERT2) != 0) transparentLayer = TRANSPARENT_2; else		if ((colorIndex&LAYERT3) != 0) transparentLayer = TRANSPARENT_3; else		if ((colorIndex&LAYERT4) != 0) transparentLayer = TRANSPARENT_4; else		if ((colorIndex&LAYERT5) != 0) transparentLayer = TRANSPARENT_5; else		if ((colorIndex&LAYERT6) != 0) transparentLayer = TRANSPARENT_6; else		if ((colorIndex&LAYERT7) != 0) transparentLayer = TRANSPARENT_7; else		if ((colorIndex&LAYERT8) != 0) transparentLayer = TRANSPARENT_8; else		if ((colorIndex&LAYERT9) != 0) transparentLayer = TRANSPARENT_9; else		if ((colorIndex&LAYERT10) != 0) transparentLayer = TRANSPARENT_10; else		if ((colorIndex&LAYERT11) != 0) transparentLayer = TRANSPARENT_11; else		if ((colorIndex&LAYERT12) != 0) transparentLayer = TRANSPARENT_12;	}	/**	 * Method to convert a Color to a color index.	 * Color indices are more general than colors, because they can handle	 * transparent layers, C-Electric-style opaque layers, and full color values.	 * Artwork nodes and arcs represent individualized color by using color indices.	 * @param color a Color object	 * @return the color index that describes that color.	 */	public static int makeIndex(Color color)	{		int red   = color.getRed();		int green = color.getGreen();		int blue  = color.getBlue();		int index = (red << 24) | (green << 16) | (blue << 8) | FULLRGBBIT;		return index;	}	/**	 * Method to convert a transparent layer to a color index.	 * Color indices are more general than colors, because they can handle	 * transparent layers, C-Electric-style opaque layers, and full color values.	 * @param transparentLayer the transparent layer number.	 * @return the color index that describes that transparent layer.	 */	public static int makeIndex(int transparentLayer)	{		switch (transparentLayer)		{			case TRANSPARENT_1: return LAYERT1;			case TRANSPARENT_2: return LAYERT2;			case TRANSPARENT_3: return LAYERT3;			case TRANSPARENT_4: return LAYERT4;			case TRANSPARENT_5: return LAYERT5;			case TRANSPARENT_6: return LAYERT6;			case TRANSPARENT_7: return LAYERT7;			case TRANSPARENT_8: return LAYERT8;			case TRANSPARENT_9: return LAYERT9;			case TRANSPARENT_10: return LAYERT10;			case TRANSPARENT_11: return LAYERT11;			case TRANSPARENT_12: return LAYERT12;		}		return 0;	}	/**	 * Method to find the index of a color, given its name.	 * @param name the name of the color.	 * @return the index of the color.	 */	public static int findColorIndex(String name)	{		if (name.equals("white"))          return WHITE;		if (name.equals("black"))          return BLACK;		if (name.equals("red"))            return RED;		if (name.equals("blue"))           return BLUE;		if (name.equals("green"))          return GREEN;		if (name.equals("cyan"))           return CYAN;		if (name.equals("magenta"))        return MAGENTA;		if (name.equals("yellow"))         return YELLOW;		if (name.equals("gray"))           return GRAY;		if (name.equals("orange"))         return ORANGE;		if (name.equals("purple"))         return PURPLE;		if (name.equals("brown"))          return BROWN;		if (name.equals("light-gray"))     return LGRAY;		if (name.equals("dark-gray"))      return DGRAY;		if (name.equals("light-red"))      return LRED;		if (name.equals("dark-red"))       return DRED;		if (name.equals("light-green"))    return LGREEN;		if (name.equals("dark-green"))     return DGREEN;		if (name.equals("light-blue"))     return LBLUE;		if (name.equals("dark-blue"))      return DBLUE;		if (name.equals("transparent-1"))  return LAYERT1;		if (name.equals("transparent-2"))  return LAYERT2;		if (name.equals("transparent-3"))  return LAYERT3;		if (name.equals("transparent-4"))  return LAYERT4;		if (name.equals("transparent-5"))  return LAYERT5;		if (name.equals("transparent-6"))  return LAYERT6;		if (name.equals("transparent-7"))  return LAYERT7;		if (name.equals("transparent-8"))  return LAYERT8;		if (name.equals("transparent-9"))  return LAYERT9;		if (name.equals("transparent-10")) return LAYERT10;		if (name.equals("transparent-11")) return LAYERT11;		if (name.equals("transparent-12")) return LAYERT12;		return 0;	}	/**	 * Method to tell the name of the color with a given index.	 * Color indices are more general than colors, because they can handle	 * transparent layers, C-Electric-style opaque layers, and full color values.	 * @param colorIndex the color number.	 * @return the name of that color.	 */	public static String getColorIndexName(int colorIndex)	{		if ((colorIndex&FULLRGBBIT) != 0)		{			int red =   (colorIndex >> 24) & 0xFF;			int green = (colorIndex >> 16) & 0xFF;			int blue =  (colorIndex >> 8) & 0xFF;			return "Color (" + red + "," + green + "," + blue + ")";		}		switch (colorIndex)		{			case WHITE:    return "white";			case BLACK:    return "black";			case RED:      return "red";			case BLUE:     return "blue";			case GREEN:    return "green";			case CYAN:     return "cyan";			case MAGENTA:  return "magenta";			case YELLOW:   return "yellow";			case GRAY:     return "gray";			case ORANGE:   return "orange";			case PURPLE:   return "purple";			case BROWN:    return "brown";			case LGRAY:    return "light-gray";			case DGRAY:    return "dark-gray";			case LRED:     return "light-red";			case DRED:     return "dark-red";			case LGREEN:   return "light-green";			case DGREEN:   return "dark-green";			case LBLUE:    return "light-blue";			case DBLUE:    return "dark-blue";			case LAYERT1:  return "transparent-1";			case LAYERT2:  return "transparent-2";			case LAYERT3:  return "transparent-3";			case LAYERT4:  return "transparent-4";			case LAYERT5:  return "transparent-5";			case LAYERT6:  return "transparent-6";			case LAYERT7:  return "transparent-7";			case LAYERT8:  return "transparent-8";			case LAYERT9:  return "transparent-9";			case LAYERT10: return "transparent-10";			case LAYERT11: return "transparent-11";			case LAYERT12: return "transparent-12";		}		return "ColorIndex "+colorIndex;	}	/**	 * Method to return the array of color indices.	 * @return an array of the possible color indices.	 */	public static int [] getColorIndices()	{		return new int [] {WHITE, BLACK, RED, BLUE, GREEN, CYAN, MAGENTA, YELLOW,			GRAY, ORANGE, PURPLE, BROWN, LGRAY, DGRAY, LRED, DRED, LGREEN, DGREEN, LBLUE, DBLUE,			LAYERT1, LAYERT2, LAYERT3, LAYERT4, LAYERT5, LAYERT6, LAYERT7, LAYERT8, LAYERT9,			LAYERT10, LAYERT11, LAYERT12};	}	/**	 * Method to return the array of transparent color indices.	 * @return an array of the possible transparent color indices.	 */	public static int [] getTransparentColorIndices()	{		return new int [] {LAYERT1, LAYERT2, LAYERT3, LAYERT4, LAYERT5, LAYERT6, LAYERT7, LAYERT8, LAYERT9,			LAYERT10, LAYERT11, LAYERT12};	}	/**	 * Method to set 3D appearance. If Java3D, Appearance class will be the type.	 * @param obj	 */	public void set3DAppearance(Object obj) {appearance3D = obj;}	/**	 * Method to retrieve current 3D appearance.	 * @return the current 3D appearance.	 */	public Object get3DAppearance() {return appearance3D;}	/**	 * Method to notify 3D observers	 * @param layerVis	 */	public void notifyVisibility(Boolean layerVis)	{		setChanged();		notifyObservers(layerVis);		clearChanged();	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -