Java Code Examples for java.awt.Color

The following are top voted examples for showing how to use java.awt.Color. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.

Example 1
Project: JAME   File: ColorChooser.java View source code 6 votes vote down vote up
/**
 * @return
 */
protected Color updateRGB() {
	final ColorFieldModel colorFieldModel = getColorFieldModel(ColorChooser.COLOR_FIELD_MODEL);
	if (colorFieldModel != null) {
		final int[] rgb = new int[4];
		SpinnerNumberModel spinnerModel = getSpinnerNumberModel(ColorChooser.SPINNER_MODEL_ALPHA);
		if (spinnerModel != null) {
			rgb[0] = spinnerModel.getNumber().intValue();
		}
		JSpinner spinner = getSpinner(ColorChooser.SPINNER_ALPHA);
		if (spinner != null) {
			spinner.setToolTipText(createSpinnerTooltip(spinnerModel));
		}
		spinnerModel = getSpinnerNumberModel(ColorChooser.SPINNER_MODEL_RED);
		if (spinnerModel != null) {
			rgb[1] = spinnerModel.getNumber().intValue();
		}
		spinner = getSpinner(ColorChooser.SPINNER_RED);
		if (spinner != null) {
			spinner.setToolTipText(createSpinnerTooltip(spinnerModel));
		}
		spinnerModel = getSpinnerNumberModel(ColorChooser.SPINNER_MODEL_GREEN);
		if (spinnerModel != null) {
			rgb[2] = spinnerModel.getNumber().intValue();
		}
		spinner = getSpinner(ColorChooser.SPINNER_GREEN);
		if (spinner != null) {
			spinner.setToolTipText(createSpinnerTooltip(spinnerModel));
		}
		spinnerModel = getSpinnerNumberModel(ColorChooser.SPINNER_MODEL_BLUE);
		if (spinnerModel != null) {
			rgb[3] = spinnerModel.getNumber().intValue();
		}
		spinner = getSpinner(ColorChooser.SPINNER_BLUE);
		if (spinner != null) {
			spinner.setToolTipText(createSpinnerTooltip(spinnerModel));
		}
		colorFieldModel.setColor(new Color(rgb[1], rgb[2], rgb[3], rgb[0]), false);
		return colorFieldModel.getColor();
	}
	return Color.BLACK;
}
 
Example 2
Project: funCKit   File: ErrorAction.java View source code 6 votes vote down vote up
/**
 * [email protected]}
 */
@Override
public void setUp(Layout layout, Settings settings, Graphics2D graphics) {
    super.setUp(layout, settings, graphics);

    errorColor = settings.get(Settings.ELEMENT_ERROR_BORDER_COLOR, Color.class);
    if (errorColor == null) {
        errorColor = Color.RED;
    }
}
 
Example 3
Project: JAME   File: ColorChooser.java View source code 6 votes vote down vote up
/**
 * @param registry
 * @return
 */
protected JPanel createColorsPanel(final Registry<Object> registry) {
	final JPanel panel = new JPanel(new GridLayout(ColorChooser.size[0], ColorChooser.size[1]));
	for (int i = 0; i < ColorChooser.size[0]; i++) {
		for (int j = 0; j < ColorChooser.size[1]; j++) {
			if (ColorChooser.colors[i][j] == null) {
				ColorChooser.colors[i][j] = Color.WHITE;
			}
			final ColorField colorField = new ColorField(ColorChooser.colors[i][j]);
			colorField.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createLineBorder(Color.GRAY)));
			colorField.getModel().addColorChangeListener(new ColorListener(i, j));
			panel.add(colorField);
		}
	}
	// final Dimension size = new Dimension(128, 128);
	// panel.setPreferredSize(size);
	// panel.setMinimumSize(size);
	// panel.setMaximumSize(size);
	panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
	panel.setOpaque(false);
	return panel;
}
 
Example 4
Project: breakout   File: XyzAxes2.java View source code 6 votes vote down vote up
/**
 * 
 * @param radius
 * @param length
 */
public XyzAxes2( float radius , float length )
{
	
	Cylinder x = new Cylinder( radius , new Point3f( ) , new Point3f( 1 , 0 , 0 ) , m_tc3f , new Color3f( Color.RED ) );
	Cylinder y = new Cylinder( radius , new Point3f( ) , new Point3f( 0 , 1 , 0 ) , m_tc3f , new Color3f( Color.GREEN ) );
	Cylinder z = new Cylinder( radius , new Point3f( ) , new Point3f( 0 , 0 , 1 ) , m_tc3f , new Color3f( Color.BLUE ) );
	
	this.addChild( x );
	this.addChild( y );
	this.addChild( z );
	
}
 
Example 5
Project: richfaces   File: ColorUtils.java View source code 6 votes vote down vote up
/**
 * Overwrites alpha value for given color.
 *
 * @param c color to overwrite
 * @param alpha a new value of alpha
 * @return a new <code>Color</code> object with a new specified alpha value
 */
public static Color overwriteAlpha(Color c, float alpha) {
    Color retVal = c;
    if (c != null) {
        retVal = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (alpha * 255 + 0.5));
    }
    return retVal;
}
 
Example 6
Project: funCKit   File: DebugAction.java View source code 6 votes vote down vote up
/**
 * [email protected]}
 */
@Override
public void prepare(Layout layout) {
    for (String shapeName : layout.getShapeMap().keySet()) {
        if (layout.getShape(shapeName) != null) {
            layout.getShape(shapeName).setBorderColor(Color.PINK);
            layout.getShape(shapeName).setFillColor(Color.GREEN);
        }
    }
}
 
Example 7
Project: funCKit   File: SimulationAction.java View source code 6 votes vote down vote up
/**
 * [email protected]}
 */
@Override
public void setUp(Layout layout, Settings settings, Graphics2D graphics) {
    super.setUp(layout, settings, graphics);
    simulationColor = settings.get(Settings.ELEMENT_SIMULATED_FILL_COLOR,
            Color.class);
    if (simulationColor == null) {
        simulationColor = Color.YELLOW;
    }
}
 
Example 8
Project: breakout   File: ColorUtils.java View source code 6 votes vote down vote up
public static Color darkerColor( Color c , double amount )
{
	float[ ] hsbvals = new float[ 3 ];
	Color.RGBtoHSB( c.getRed( ) , c.getGreen( ) , c.getBlue( ) , hsbvals );
	hsbvals[ 2 ] = Math.min( 1f , Math.max( 0f , ( float ) ( hsbvals[ 2 ] - amount ) ) );
	int rgb = Color.HSBtoRGB( hsbvals[ 0 ] , hsbvals[ 1 ] , hsbvals[ 2 ] );
	rgb |= c.getAlpha( ) << 24;
	return new Color( rgb , true );
}
 
Example 9
Project: breakout   File: HighlightingTableScroller.java View source code 6 votes vote down vote up
@Override
public void paint(Graphics g) {
	super.paint(g);

	TableModel model = table.getModel();
	if (model instanceof FilteringTableModel) {
		filteringModel = (FilteringTableModel) model;
	} else {
		filteringModel = null;
	}

	Graphics2D g2 = (Graphics2D) g;
	Paint prevPaint = g2.getPaint();

	Insets insets = getInsets();
	int buttonSize = 20;
	int xPadding = 4;

	int scrollArea = getHeight() - insets.top - insets.bottom - buttonSize * 2;

	int markerWidth = getWidth() - insets.left - insets.right - xPadding * 2;

	for (int row = 0; row < table.getRowCount(); row++) {
		Color rowColor = getRowColor(row);

		if (rowColor != null) {
			int startY = buttonSize - 1 + row * scrollArea / table.getRowCount();

			while (row < table.getRowCount() - 1 && rowColor.equals(getRowColor(row + 1))) {
				row++;
			}

			int endY = buttonSize - 1 + (row + 1) * scrollArea / table.getRowCount();
			endY = Math.max(endY, startY + 3);

			g2.setColor(new Color(rowColor.getRed(), rowColor.getGreen(), rowColor.getBlue(), 64));
			g2.fillRect(insets.left + xPadding, startY, markerWidth, endY - startY);
			g2.setColor(getDarkerColor(rowColor, 0.3f, 128));
			g2.drawRect(insets.left + xPadding, startY, markerWidth, endY - startY);
		}
	}

	g2.setPaint(prevPaint);
}
 
Example 10
Project: JAME   File: DefaultColorFieldModel.java View source code 6 votes vote down vote up
/**
 * @see net.sf.jame.core.swing.color.ColorFieldModel#setColor(java.awt.Color, boolean)
 */
public void setColor(final Color color, final boolean isAdjusting) {
	if (color == null) {
		throw new NullPointerException("color == null");
	}
	if ((this.color != color) && (this.color.getRGB() != color.getRGB())) {
		this.color = color;
		fireColorChangeEvent(new ColorChangeEvent(this, isAdjusting));
	}
}
 
Example 11
Project: richfaces   File: MenuNodeImage.java View source code 6 votes vote down vote up
@PostConstructResource
public final void initialize() {
    FacesContext context = FacesContext.getCurrentInstance();
    Skin skin = SkinFactory.getInstance(context).getSkin(context);
    Skin defaultSkin = SkinFactory.getInstance(context).getDefaultSkin(context);

    String skinParameter = "generalTextColor";
    String tmp = (String) skin.getParameter(context, skinParameter);
    if (null == tmp || "".equals(tmp)) {
        tmp = (String) defaultSkin.getParameter(context, skinParameter);
    }

    this.setGeneralColor(Color.decode(tmp == null ? "#4A75B5" : tmp).getRGB());

    skinParameter = "tabDisabledTextColor";
    tmp = (String) skin.getParameter(context, skinParameter);
    if (null == tmp || "".equals(tmp)) {
        tmp = (String) defaultSkin.getParameter(context, skinParameter);
    }
    this.setDisabledColor(Color.decode(tmp == null ? "#6A92CF" : tmp).getRGB());
}
 
Example 12
Project: JAME   File: ColorChooser.java View source code 6 votes vote down vote up
/**
 * @param color
 */
protected void setHSB(final Color color) {
	final float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]);
	SpinnerNumberModel spinnerModel = getSpinnerNumberModel(ColorChooser.SPINNER_MODEL_HUE);
	if (spinnerModel != null) {
		spinnerModel.setValue(Math.round(hsb[0] * 255f));
	}
	JSpinner spinner = getSpinner(ColorChooser.SPINNER_HUE);
	if (spinner != null) {
		spinner.setToolTipText(createSpinnerTooltip(spinnerModel));
	}
	spinnerModel = getSpinnerNumberModel(ColorChooser.SPINNER_MODEL_SATURATION);
	if (spinnerModel != null) {
		spinnerModel.setValue(Math.round(hsb[1] * 255f));
	}
	spinner = getSpinner(ColorChooser.SPINNER_SATURATION);
	if (spinner != null) {
		spinner.setToolTipText(createSpinnerTooltip(spinnerModel));
	}
	spinnerModel = getSpinnerNumberModel(ColorChooser.SPINNER_MODEL_BRIGHTNESS);
	if (spinnerModel != null) {
		spinnerModel.setValue(Math.round(hsb[2] * 255f));
	}
	spinner = getSpinner(ColorChooser.SPINNER_BRIGHTNESS);
	if (spinner != null) {
		spinner.setToolTipText(createSpinnerTooltip(spinnerModel));
	}
}
 
Example 13
Project: richfaces   File: ColorUtils.java View source code 6 votes vote down vote up
/**
 * Increases/decreases brightness of the given color by the specified <code>difference</code>.
 * <p>
 * The <code>difference</code> values in the range (-1.0, 1.0): 1.0 - the brightest value; -1.0 - the dimmest value.
 *
 * @param c color to adjust
 * @param difference value to be added to the current brightness
 *
 * @return a new <code>Color</code> instance with increased/decreased brightness by specified <code>difference</code>
 * @throws IllegalArgumentException if difference is outside of the range -1.0 to 1.0, inclusive
 */
public static Color adjustBrightness(Color c, float difference) {
    if (difference < -1.0 || difference > 1.0) {
        throw new IllegalArgumentException("Difference parameter outside of expected range: "
            + "Difference parameter should be floating-point values between -1 and 1");
    }

    Color retVal = null;
    if (c != null) {
        float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
        float brightness = Math.min(1.0f, Math.max(0.0f, hsb[2] + difference));
        retVal = new Color(Color.HSBtoRGB(hsb[0], hsb[1], brightness));
    }

    return retVal;
}
 
Example 14
Project: JAME   File: CFPath.java View source code 6 votes vote down vote up
public void render(Graphics2D g2d, CFPathAttribute attribute, Point2D.Double point) {
	CFColor c = attribute.getModification().getColor();
	Color color = Color.getHSBColor(c.getHue() / 360, c.getSaturation(), c.getBrightness());
	Composite composite = AlphaComposite.SrcAtop.derive(c.getAlpha());
	AffineTransform tmpTransform = g2d.getTransform();
	Composite tmpComposite = g2d.getComposite();
	Color tmpColor = g2d.getColor();
	g2d.setComposite(composite);
	g2d.setColor(color);
	if (point != null) {
		g2d.translate(point.getX(), point.getY());
	}
	g2d.transform(attribute.getModification().getTransform());
	if (path != null) {
		if (attribute.getCommand().equals(CFPathCommand.FILL)) {
			path.setWindingRule(attribute.getWindingRule());
			g2d.fill(path);
		} else {
			g2d.setStroke(attribute.getStroke());
			g2d.draw(path);
		}
	}
	g2d.setTransform(tmpTransform);
	g2d.setComposite(tmpComposite);
	g2d.setColor(tmpColor);
}
 
Example 15
Project: OsmUi   File: GraphEditor.java View source code 6 votes vote down vote up
/**
 * 
 * @param args
 */
public static void main(String[] args)
{
	try
	{
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	}
	catch (Exception e1)
	{
		e1.printStackTrace();
	}

	mxConstants.SHADOW_COLOR = Color.LIGHT_GRAY;
	GraphEditor editor = new GraphEditor();
	editor.createFrame(new EditorMenuBar(editor)).setVisible(true);
}
 
Example 16
Project: Thud   File: ANSIEmulation.java View source code 6 votes vote down vote up
static private Color getColor (final char ch) {
	switch (ch) {
	case 'x': // black
		return Color.BLACK;

	case 'r': // red
		return Color.RED;

	case 'g': // green
		return Color.GREEN;

	case 'y': // yellow
		return Color.YELLOW;

	case 'b': // blue
		return Color.BLUE;

	case 'm': // magenta
		return Color.MAGENTA;

	case 'c': // cyan
		return Color.CYAN;

	case 'w': // white
		return Color.WHITE;

	default: // ???
		throw new IllegalArgumentException ("Bad ANSI style");
	}
}
 
Example 17
Project: sysart-itext   File: PageNumbersWatermark.java View source code 6 votes vote down vote up
/**
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onOpenDocument(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
 */
public void onOpenDocument(PdfWriter writer, Document document) {
    try {
    	// initialization of the header table
        headerImage = Image.getInstance("logo.gif");
        table = new PdfPTable(2);
        Phrase p = new Phrase();
        Chunk ck = new Chunk("lowagie.com\n", new Font(Font.TIMES_ROMAN, 16, Font.BOLDITALIC, Color.blue));
        p.add(ck);
        ck = new Chunk("Ghent\nBelgium", new Font(Font.HELVETICA, 12, Font.NORMAL, Color.darkGray));
        p.add(ck);
        table.getDefaultCell().setBackgroundColor(Color.yellow);
        table.getDefaultCell().setBorderWidth(0);
        table.addCell(p);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(new Phrase(new Chunk(headerImage, 0, 0)));
        // initialization of the Graphic State
        gstate = new PdfGState();
        gstate.setFillOpacity(0.3f);
        gstate.setStrokeOpacity(0.3f);
        // initialization of the template
        tpl = writer.getDirectContent().createTemplate(100, 100);
        tpl.setBoundingBox(new Rectangle(-20, -20, 100, 100));
        // initialization of the font
        helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
    }
    catch(Exception e) {
        throw new ExceptionConverter(e);
    }
}
 
Example 18
Project: personal   File: AttributePanel.java View source code 6 votes vote down vote up
/**
  * Adds more colours to the colour list
  */
 private void extendColourMap() {
   if (m_plotInstances.attribute(m_cIndex).isNominal()) {
     for (int i = m_colorList.size(); 
   i < m_plotInstances.attribute(m_cIndex).numValues();
   i++) {
Color pc = m_DefaultColors[i % 10];
int ija =  i / 10;
ija *= 2; 
for (int j=0;j<ija;j++) {
  pc = pc.brighter();
}

if (m_backgroundColor != null) {
  pc = Plot2D.checkAgainstBackground(pc, m_backgroundColor);
}

m_colorList.addElement(pc);
     }
   }
 }
 
Example 19
Project: OsmUi   File: ShadowBorder.java View source code 6 votes vote down vote up
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
{
	// choose which colors we want to use
	Color bg = c.getBackground();

	if (c.getParent() != null)
	{
		bg = c.getParent().getBackground();
	}

	if (bg != null)
	{
		Color mid = bg.darker();
		Color edge = average(mid, bg);

		g.setColor(bg);
		g.drawLine(0, h - 2, w, h - 2);
		g.drawLine(0, h - 1, w, h - 1);
		g.drawLine(w - 2, 0, w - 2, h);
		g.drawLine(w - 1, 0, w - 1, h);

		// draw the drop-shadow
		g.setColor(mid);
		g.drawLine(1, h - 2, w - 2, h - 2);
		g.drawLine(w - 2, 1, w - 2, h - 2);

		g.setColor(edge);
		g.drawLine(2, h - 1, w - 2, h - 1);
		g.drawLine(w - 1, 2, w - 1, h - 2);
	}
}
 
Example 20
Project: JAME   File: MandelbrotConfigPanel.java View source code 6 votes vote down vote up
/**
 * @param config
 * @param viewContext
 * @param context
 * @param session
 */
public MandelbrotConfigPanel(final MandelbrotConfig config, final ViewContext viewContext, final RenderContext context, final NodeSession session) {
	this.viewContext = viewContext;
	this.context = context;
	this.session = session;
	this.config = config;
	oddColor = getBackground().brighter();
	evenColor = getBackground().brighter();
	imagePanel = new MandelbrotImagePanel(config);
	fractalPanel = new MandelbrotFractalPanel(config, config.getMandelbrotFractal());
	setLayout(new StackLayout());
	add(fractalPanel);
	add(imagePanel);
	setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, Color.DARK_GRAY));
	configListener = new ValueChangeListener() {
		public void valueChanged(final ValueChangeEvent e) {
			switch (e.getEventType()) {
				case ValueConfigElement.VALUE_CHANGED: {
					remove(fractalPanel);
					fractalPanel.dispose();
					fractalPanel = new MandelbrotFractalPanel(config, config.getMandelbrotFractal());
					add(fractalPanel, BorderLayout.CENTER);
					viewContext.setComponent(MandelbrotConfigPanel.this);
					break;
				}
				default: {
					break;
				}
			}
		}
	};
	config.getFractalSingleElement().addChangeListener(configListener);
}
 
Example 21
Project: closure-stylesheets   File: GssFunctions.java View source code 6 votes vote down vote up
protected CssValueNode makeTranslucent(
    String inputColorStr, String alphaStr,
    @Nullable SourceCodeLocation sourceCodeLocation) {
  Color inputColor = ColorParser.parseAny(inputColorStr);
  double alpha = Math.min(1.0, Math.max(0, Float.parseFloat(alphaStr)));

  float[] rgb = inputColor.getRGBColorComponents(null);
  Color outputColor = new Color(rgb[0], rgb[1], rgb[2], (float) alpha);

  List<CssValueNode> argList = ImmutableList.<CssValueNode>of(
      new CssLiteralNode(
          Integer.toString(outputColor.getRed()), sourceCodeLocation),
      new CssLiteralNode(
          Integer.toString(outputColor.getGreen()), sourceCodeLocation),
      new CssLiteralNode(
          Integer.toString(outputColor.getBlue()), sourceCodeLocation),
      new CssLiteralNode(
          new DecimalFormat("#.###", US_SYMBOLS).format(outputColor.getAlpha() / 255f),
          sourceCodeLocation));
  CssValueNode argsValue = new CssCompositeValueNode(
      argList, CssCompositeValueNode.Operator.COMMA,
      sourceCodeLocation);
  CssFunctionNode result = new CssFunctionNode(
      CssFunctionNode.Function.byName("rgba"),
      sourceCodeLocation);
  result.setArguments(new CssFunctionArgumentsNode(
      ImmutableList.of(argsValue)));
  return result;
}
 
Example 22
Project: ilarkesto   File: Colors.java View source code 6 votes vote down vote up
public static Color blend(Color one, Color two, float ratio) {
	if (ratio < 0 || ratio > 1) throw new IllegalArgumentException("Color blend ratio r must be between 0 and 1.");

	float r1 = ratio;
	float r2 = 1 - ratio;

	float[] rgb1 = new float[3];
	float[] rgb2 = new float[3];
	one.getColorComponents(rgb1);
	two.getColorComponents(rgb2);

	return new Color(rgb1[0] * r1 + rgb2[0] * r2, rgb1[1] * r1 + rgb2[1] * r2, rgb1[2] * r1 + rgb2[2] * r2);
}
 
Example 23
Project: earthsci   File: ColorMapTest.java View source code 6 votes vote down vote up
private static void assertColorsEqual(Color expected, Color actual)
{
	if (expected == null)
	{
		assertNull(actual);
		return;
	}
	assertNotNull(actual);

	float[] expectedRGBA = expected.getRGBComponents(null);
	float[] actualRGBA = actual.getRGBComponents(null);

	assertEquals(expectedRGBA[0], actualRGBA[0], 0.001);
	assertEquals(expectedRGBA[1], actualRGBA[1], 0.001);
	assertEquals(expectedRGBA[2], actualRGBA[2], 0.001);
	assertEquals(expectedRGBA[3], actualRGBA[3], 0.001);
}
 
Example 24
Project: TFC2   File: PrintImageMapCommand.java View source code 6 votes vote down vote up
public PrintImageMapCommand()
{
	for(int i = 0; i < 256; i++)
	{
		colorMap[i] = Color.getColor("", (i << 16) + (i << 8) + i);
	}
}
 
Example 25
Project: ikvm-openjdk   File: BlitBg.java View source code 6 votes vote down vote up
public void BlitBg(SurfaceData srcData,
                   SurfaceData dstData,
                   Composite comp,
                   Region clip,
                   Color bgColor,
                   int srcx, int srcy,
                   int dstx, int dsty,
                   int width, int height)
{
    ColorModel dstModel = dstData.getColorModel();
    if (!dstModel.hasAlpha() &&
        bgColor.getTransparency() != Transparency.OPAQUE)
    {
        dstModel = ColorModel.getRGBdefault();
    }
    WritableRaster wr =
        dstModel.createCompatibleWritableRaster(width, height);
    boolean isPremult = dstModel.isAlphaPremultiplied();
    BufferedImage bimg =
        new BufferedImage(dstModel, wr, isPremult, null);
    SurfaceData tmpData = BufImgSurfaceData.createData(bimg);
    SunGraphics2D sg2d = new SunGraphics2D(tmpData, bgColor, bgColor,
                                           defaultFont);
    FillRect fillop = FillRect.locate(SurfaceType.AnyColor,
                                      CompositeType.SrcNoEa,
                                      tmpData.getSurfaceType());
    Blit combineop = Blit.getFromCache(srcData.getSurfaceType(),
                                       CompositeType.SrcOverNoEa,
                                       tmpData.getSurfaceType());
    Blit blitop = Blit.getFromCache(tmpData.getSurfaceType(), compositeType,
                                    dstData.getSurfaceType());
    fillop.FillRect(sg2d, tmpData, 0, 0, width, height);
    combineop.Blit(srcData, tmpData, AlphaComposite.SrcOver, null,
                   srcx, srcy, 0, 0, width, height);
    blitop.Blit(tmpData, dstData, comp, clip,
                0, 0, dstx, dsty, width, height);
}
 
Example 26
Project: castor   File: MySimpleHandler.java View source code 6 votes vote down vote up
public Object convertUponGet(Object value) {
    if (value == null) {
        return null;
    }
    Color c = (Color) value;
    return c.toString();
}
 
Example 27
Project: OsmUi   File: mxUtils.java View source code 5 votes vote down vote up
/**
 * Convert a string representing a 24/32bit hex color value into a Color
 * object. The following color names are also supported: white, black, red,
 * green, blue, orange, yellow, pink, turquoise, gray and none (null).
 * Examples of possible hex color values are: #C3D9FF, #6482B9 and #774400,
 * but note that you do not include the "#" in the string passed in
 * 
 * @param colorString
 *            the 24/32bit hex string value (ARGB)
 * @return java.awt.Color (24bit RGB on JDK 1.1, 24/32bit ARGB on JDK1.2)
 * @exception NumberFormatException
 *                if the specified string cannot be interpreted as a
 *                hexidecimal integer
 */
public static Color parseColor(String colorString)
		throws NumberFormatException
{
	if (colorString.equalsIgnoreCase("white"))
	{
		return Color.white;
	}
	else if (colorString.equalsIgnoreCase("black"))
	{
		return Color.black;
	}
	else if (colorString.equalsIgnoreCase("red"))
	{
		return Color.red;
	}
	else if (colorString.equalsIgnoreCase("green"))
	{
		return Color.green;
	}
	else if (colorString.equalsIgnoreCase("blue"))
	{
		return Color.blue;
	}
	else if (colorString.equalsIgnoreCase("orange"))
	{
		return Color.orange;
	}
	else if (colorString.equalsIgnoreCase("yellow"))
	{
		return Color.yellow;
	}
	else if (colorString.equalsIgnoreCase("pink"))
	{
		return Color.pink;
	}
	else if (colorString.equalsIgnoreCase("turqoise"))
	{
		return new Color(0, 255, 255);
	}
	else if (colorString.equalsIgnoreCase("gray"))
	{
		return Color.gray;
	}
	else if (colorString.equalsIgnoreCase("none"))
	{
		return null;
	}

	int value;
	try
	{
		value = (int) Long.parseLong(colorString, 16);
	}
	catch (NumberFormatException nfe)
	{
		value = Long.decode(colorString).intValue();
	}

	return new Color(value);
}
 
Example 28
Project: Thud   File: MUPrefs.java View source code 5 votes vote down vote up
/**
    * Set default prefs
    */
   public void defaultPrefs()
   {
       // Set some initial values
       showTacMap = true;
       showContacts = true;

       antiAliasText = false;
       contactsAge = 30;
       
       mainSizeX = 580;
       mainSizeY = 580;

       tacSizeX = 560;
       tacSizeY = 560;

       contactsSizeX = 560;
       contactsSizeY = 250;
       
       statusSizeX = 530;
       statusSizeY = 250;
       
       armorSizeX = 200;
       armorSizeY = 250;

       mainLoc = new Point(10, 10);
       tacLoc = new Point(20 + mainSizeX, 10);
       contactsLoc = new Point(10, 30 + mainSizeY);
       statusLoc = new Point(10,60 + mainSizeY);
       armorLoc = new Point(20 + mainSizeX, 30 + tacSizeY);
       
       commandHistory = 20;
       echoCommands = true;

       fastCommandUpdate = 1.0;
       mediumCommandUpdate = 2.0;
       slowCommandUpdate = 5.0;
       slugCommandUpdate = 20.0;
       
       hudinfoTacHeight = 40;
       elevationColorMultiplier = 0.08f;

       hexHeight = 40;
       tacShowHexNumbers = false;
       tacShowTerrainChar = true;
       tacShowTerrainElev = true;
       tacShowUnitNames = true;
       tacDarkenElev = true;
       tacShowCliffs = true;
       tacShowIndicators = true;      // Floating Heat/Armor/Internal bar on tactical map
       tacShowArmorDiagram = true;
       highlightMyHex = true;
       speedIndicatorLength = 3.0f;
       tacShowLOSInfo = false;	
       
       makeArcsWeaponRange = false;
       tacShowArcs = true;
       arcIndicatorRange = 2;

       yOffset = 0;
       xOffset = 0;

       backgroundColor = Color.black;
       foregroundColor = Color.white;

       terrainColors[MUHex.PLAIN] = Color.white;
       terrainColors[MUHex.WATER] = Color.blue;
       terrainColors[MUHex.LIGHT_FOREST] = Color.green;
       terrainColors[MUHex.HEAVY_FOREST] = Color.green;
       terrainColors[MUHex.MOUNTAIN] = Color.yellow;
       terrainColors[MUHex.ROUGH] = Color.yellow;
       terrainColors[MUHex.BUILDING] = Color.magenta;
       terrainColors[MUHex.ROAD] = Color.lightGray;
       terrainColors[MUHex.BRIDGE] = Color.lightGray;
       terrainColors[MUHex.FIRE] = Color.red;
       terrainColors[MUHex.WALL] = Color.orange;
       terrainColors[MUHex.ICE] = Color.white;
       terrainColors[MUHex.SMOKE] = Color.lightGray;
       terrainColors[MUHex.SMOKE_OVER_WATER] = Color.lightGray;
       terrainColors[MUHex.UNKNOWN] = Color.black;
       
       // Need to get the "real" font name for the Monospaced font
       mainFont = new Font("Monospaced",Font.PLAIN,10).getFontName();
       mainFontSize = 12;
       contactFontSize = 12;
       tacStatusFontSize = 9;
       hexNumberFontSize = 9;
       infoFontSize = 10;
       statusFontSize = 12;
       elevationFontSize = 10;

       maxScrollbackSize = 2000;

childrenAreFrames = false;
       mainAlwaysOnTop = false;
       contactsAlwaysOnTop = false;
       statusAlwaysOnTop = false;
       tacticalAlwaysOnTop = false;
       
       MUHost bt3030 = new MUHost("btech.dhs.org", 3030);
       MUHost frontiers = new MUHost("frontiermux.com", 5555);
       MUHost bt3027 = new MUHost("btmux.com", 3027);        

       hosts.add(bt3030);
       hosts.add(frontiers);
       hosts.add(bt3027);
   }