List of usage examples for java.awt Graphics setColor
public abstract void setColor(Color c);
From source file:com.cburch.logisim.circuit.CircuitWires.java
void draw(ComponentDrawContext context, Collection<Component> hidden) { boolean showState = context.getShowState(); CircuitState state = context.getCircuitState(); Graphics g = context.getGraphics(); g.setColor(Color.BLACK); GraphicsUtil.switchToWidth(g, Wire.WIDTH); WireSet highlighted = context.getHighlightedWires(); BundleMap bmap = getBundleMap();//from w w w . j a va 2 s .c o m boolean isValid = bmap.isValid(); if (hidden == null || hidden.size() == 0) { for (Wire w : wires) { Location s = w.e0; Location t = w.e1; WireBundle wb = bmap.getBundleAt(s); if (!wb.isValid()) { g.setColor(Value.WIDTH_ERROR_COLOR); } else if (showState) { if (!isValid) g.setColor(Value.NIL_COLOR); else g.setColor(state.getValue(s).getColor()); } else { g.setColor(Color.BLACK); } if (highlighted.containsWire(w)) { GraphicsUtil.switchToWidth(g, Wire.WIDTH + 2); g.drawLine(s.getX(), s.getY(), t.getX(), t.getY()); GraphicsUtil.switchToWidth(g, Wire.WIDTH); } else { g.drawLine(s.getX(), s.getY(), t.getX(), t.getY()); } } for (Location loc : points.getSplitLocations()) { if (points.getComponentCount(loc) > 2) { WireBundle wb = bmap.getBundleAt(loc); if (wb != null) { if (!wb.isValid()) { g.setColor(Value.WIDTH_ERROR_COLOR); } else if (showState) { if (!isValid) g.setColor(Value.NIL_COLOR); else g.setColor(state.getValue(loc).getColor()); } else { g.setColor(Color.BLACK); } if (highlighted.containsLocation(loc)) { g.fillOval(loc.getX() - 5, loc.getY() - 5, 10, 10); } else { g.fillOval(loc.getX() - 4, loc.getY() - 4, 8, 8); } } } } } else { for (Wire w : wires) { if (!hidden.contains(w)) { Location s = w.e0; Location t = w.e1; WireBundle wb = bmap.getBundleAt(s); if (!wb.isValid()) { g.setColor(Value.WIDTH_ERROR_COLOR); } else if (showState) { if (!isValid) g.setColor(Value.NIL_COLOR); else g.setColor(state.getValue(s).getColor()); } else { g.setColor(Color.BLACK); } if (highlighted.containsWire(w)) { GraphicsUtil.switchToWidth(g, Wire.WIDTH + 2); g.drawLine(s.getX(), s.getY(), t.getX(), t.getY()); GraphicsUtil.switchToWidth(g, Wire.WIDTH); } else { g.drawLine(s.getX(), s.getY(), t.getX(), t.getY()); } } } // this is just an approximation, but it's good enough since // the problem is minor, and hidden only exists for a short // while at a time anway. for (Location loc : points.getSplitLocations()) { if (points.getComponentCount(loc) > 2) { int icount = 0; for (Component comp : points.getComponents(loc)) { if (!hidden.contains(comp)) ++icount; } if (icount > 2) { WireBundle wb = bmap.getBundleAt(loc); if (wb != null) { if (!wb.isValid()) { g.setColor(Value.WIDTH_ERROR_COLOR); } else if (showState) { if (!isValid) g.setColor(Value.NIL_COLOR); else g.setColor(state.getValue(loc).getColor()); } else { g.setColor(Color.BLACK); } if (highlighted.containsLocation(loc)) { g.fillOval(loc.getX() - 5, loc.getY() - 5, 10, 10); } else { g.fillOval(loc.getX() - 4, loc.getY() - 4, 8, 8); } } } } } } }
From source file:CustomAlphaTest.java
protected void drawAlpha(Graphics g, long lMaxTime) { g.setColor(Color.blue); float value = 0; double x1 = 0; double y1 = 0; double x2 = 0; double y2 = 0; for (long lTime = 0; lTime <= lMaxTime; lTime += m_kTimeStep) { value = m_Alpha.value(lTime);/* w w w . ja v a2s .com*/ x2 = lTime * m_ScaleX; y2 = value * m_nGraphMaxHeight; drawGraphLine(g, x1, y1, x2, y2); x1 = x2; y1 = y2; } g.setColor(Color.black); }
From source file:SortableTable.java
/** * Draws the arrow pointing down.//from ww w .j ava 2s . c o m * * @param g the graphics device. * @param xo ?? * @param yo ?? */ private void drawDownArrow(final Graphics g, final int xo, final int yo) { g.setColor(this.edge1); g.drawLine(xo, yo, xo + this.size - 1, yo); g.drawLine(xo, yo + 1, xo + this.size - 3, yo + 1); g.setColor(this.edge2); g.drawLine(xo + this.size - 2, yo + 1, xo + this.size - 1, yo + 1); int x = xo + 1; int y = yo + 2; int dx = this.size - 6; while (y + 1 < yo + this.size) { g.setColor(this.edge1); g.drawLine(x, y, x + 1, y); g.drawLine(x, y + 1, x + 1, y + 1); if (0 < dx) { g.setColor(this.fill); g.drawLine(x + 2, y, x + 1 + dx, y); g.drawLine(x + 2, y + 1, x + 1 + dx, y + 1); } g.setColor(this.edge2); g.drawLine(x + dx + 2, y, x + dx + 3, y); g.drawLine(x + dx + 2, y + 1, x + dx + 3, y + 1); x += 1; y += 2; dx -= 2; } g.setColor(this.edge1); g.drawLine(xo + (this.size / 2), yo + this.size - 1, xo + (this.size / 2), yo + this.size - 1); }
From source file:SortableTable.java
/** * Draws the arrow pointing up.//from w w w. j a v a 2 s.c om * * @param g the graphics device. * @param xo ?? * @param yo ?? */ private void drawUpArrow(final Graphics g, final int xo, final int yo) { g.setColor(this.edge1); int x = xo + (this.size / 2); g.drawLine(x, yo, x, yo); x--; int y = yo + 1; int dx = 0; while (y + 3 < yo + this.size) { g.setColor(this.edge1); g.drawLine(x, y, x + 1, y); g.drawLine(x, y + 1, x + 1, y + 1); if (0 < dx) { g.setColor(this.fill); g.drawLine(x + 2, y, x + 1 + dx, y); g.drawLine(x + 2, y + 1, x + 1 + dx, y + 1); } g.setColor(this.edge2); g.drawLine(x + dx + 2, y, x + dx + 3, y); g.drawLine(x + dx + 2, y + 1, x + dx + 3, y + 1); x -= 1; y += 2; dx += 2; } g.setColor(this.edge1); g.drawLine(xo, yo + this.size - 3, xo + 1, yo + this.size - 3); g.setColor(this.edge2); g.drawLine(xo + 2, yo + this.size - 2, xo + this.size - 1, yo + this.size - 2); g.drawLine(xo, yo + this.size - 1, xo + this.size, yo + this.size - 1); }
From source file:CustomAlphaTest.java
protected void drawGraph() { if (m_Alpha != null) { Graphics g = m_Image.getGraphics(); g.setColor(Color.white); g.fillRect(0, 0, m_kWidth, m_kHeight); g.setColor(Color.black);/*from ww w .jav a 2s.c om*/ m_Alpha.setStartTime(0); long lMaxTime = getMaxTime(); computeDrawScale(lMaxTime); drawAxes(g, lMaxTime); drawPhases(g, lMaxTime); drawAlpha(g, lMaxTime); } }
From source file:edu.ku.brc.stats.StatGroupTable.java
/** * Overrides paint to draw in name at top with separator AND the Label *//* www . j a v a 2s . c om*/ public void paint(Graphics g) { super.paint(g); if (!useSeparator) { Dimension dim = getSize(); FontMetrics fm = g.getFontMetrics(); int strW = fm.stringWidth(name); int x = (dim.width - strW) / 2; Insets ins = getBorder().getBorderInsets(this); int y = 2 + fm.getAscent(); int lineW = dim.width - ins.left - ins.right; g.setColor(Color.BLUE.darker()); g.drawString(name, x, y); x = ins.left; y += fm.getDescent() + fm.getLeading(); g.setColor(Color.LIGHT_GRAY.brighter()); g.drawLine(x, y, x + lineW, y); y++; x++; g.setColor(Color.LIGHT_GRAY); g.drawLine(x, y, x + lineW, y); } }
From source file:com.floreantpos.jasperreport.swing.JRViewerPanel.java
protected void drawPageError(Graphics grx) { grx.setColor(Color.white); grx.fillRect(0, 0, viewerContext.getJasperPrint().getPageWidth() + 1, viewerContext.getJasperPrint().getPageHeight() + 1); }
From source file:CustomAlphaTest.java
protected void drawPhases(Graphics g, long lMaxTime) { double curTime = 0; g.setColor(Color.darkGray); int nLoop = 1; if (m_Alpha.getLoopCount() > 0) nLoop = m_Alpha.getLoopCount();/*from w ww . ja va 2 s . c om*/ for (int n = 0; n < nLoop; n++) { for (int nValue = 0; nValue < m_Alpha.getNumValues(); nValue++) { curTime = n * m_Alpha.getMaxTime() + m_Alpha.getTimeForValue(nValue); g.setColor(Color.black); drawGraphString(g, -1, "" + (curTime / 1000), curTime * m_ScaleX, -20); g.setColor(Color.darkGray); drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight); } } g.setColor(Color.black); }
From source file:BeanContainer.java
public void paint(Graphics g) { super.paint(g); if (m_activeBean == null) return;/*from ww w.ja v a 2s.c om*/ Point pt = getLocationOnScreen(); Point pt1 = m_activeBean.getLocationOnScreen(); int x = pt1.x - pt.x - 2; int y = pt1.y - pt.y - 2; int w = m_activeBean.getWidth() + 2; int h = m_activeBean.getHeight() + 2; g.setColor(Color.black); g.drawRect(x, y, w, h); }
From source file:org.jtrfp.trcl.core.ResourceManager.java
/** * Returns RAW image as an R8-G8-B8 buffer with a side-width which is the square root of the total number of pixels * @param name/*w ww .j a v a 2 s .co m*/ * @param palette * @param proc * @return * @throws IOException * @throws FileLoadException * @throws IllegalAccessException * @throws NotSquareException * @since Oct 26, 2012 */ public BufferedImage getRAWImage(String name, Color[] palette) throws IOException, FileLoadException, IllegalAccessException, NotSquareException, NonPowerOfTwoException { final RAWFile dat = getRAW(name); final byte[] raw = dat.getRawBytes(); if (raw.length != dat.getSideLength() * dat.getSideLength()) throw new NotSquareException(name); if ((dat.getSideLength() & (dat.getSideLength() - 1)) != 0) throw new NonPowerOfTwoException(name); final BufferedImage stamper = new BufferedImage(dat.getSideLength(), dat.getSideLength(), BufferedImage.TYPE_INT_ARGB); Graphics stG = stamper.getGraphics(); for (int i = 0; i < raw.length; i++) { Color c = palette[(int) raw[i] & 0xFF]; stG.setColor(c); stG.fillRect(i % dat.getSideLength(), i / dat.getSideLength(), 1, 1); } stG.dispose(); Graphics g = stamper.getGraphics(); //The following code stamps the filename into the texture for debugging purposes if (tr.isStampingTextures()) { g.setFont(new Font(g.getFont().getName(), g.getFont().getStyle(), 9)); g.drawString(name, 1, 16); } g.dispose(); return stamper; }