/** Overrides <code>Graphics.fillOval</code>. */ public void fillOval(int x, int y, int width, int height) { DebugGraphicsInfo info = info(); if (debugLog()) { info().log(toShortString() + " Filling oval: " + new Rectangle(x, y, width, height)); } if (isDrawingBuffer()) { if (debugBuffered()) { Graphics debugGraphics = debugGraphics(); debugGraphics.fillOval(x, y, width, height); debugGraphics.dispose(); } } else if (debugFlash()) { Color oldColor = getColor(); int i, count = (info.flashCount * 2) - 1; for (i = 0; i < count; i++) { graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor); graphics.fillOval(x, y, width, height); Toolkit.getDefaultToolkit().sync(); sleep(info.flashTime); } graphics.setColor(oldColor); } graphics.fillOval(x, y, width, height); }
public void draw(Graphics window, int x, int y) { window.setColor(Color.CYAN); window.fillOval(x + 8, y + 11, 45 - 16, 45 - 16); window.setColor(Color.BLACK); window.fillOval(x + 14, y + 15, 5, 5); // eyes window.fillOval(x + 25, y + 15, 5, 5); // eyes imgFound = false; // health bar window.setColor(Color.RED); window.fillRect(x, y, 45, 9); window.setColor(Color.GREEN); window.fillRect(x, y, (int) ((double) currentHealth / (double) (maxHealth) * 45), 9); }
/** * Draw character in minimap * * @param g Graphics * @param Dx X Displacement * @param Dy Y Displacement */ public void MapDraw(Graphics g, int Dx, int Dy, double Scale, Color col) { // Color g.setColor(col.darker().darker().darker()); g.drawOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7); g.setColor(col); g.fillOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7); }
public void draw(Graphics window, int scale, int x, int y) { window.setColor(Color.CYAN); window.fillOval( x + 8 * scale / 45, y + 11 * scale / 45, scale - 16 * scale / 45, scale - 16 * scale / 45); window.setColor(Color.BLACK); window.fillOval( x + 14 * scale / 45, y + 15 * scale / 45, 5 * scale / 45, 5 * scale / 45); // eyes window.fillOval( x + 25 * scale / 45, y + 15 * scale / 45, 5 * scale / 45, 5 * scale / 45); // eyes imgFound = false; // health bar window.setColor(Color.RED); window.fillRect(x, y, scale - 1, 9 * scale / 45); window.setColor(Color.GREEN); window.fillRect( x, y, (int) ((double) currentHealth / (double) (maxHealth) * (scale - 1)), 9 * scale / 45); }
void drawPoint(Graphics g, DrawObject p) { if (p == null) { return; } if ((sequencingOn) && (p.sequenceNum != currentSequenceNumDisplay)) { return; } int x = (int) ((p.x - minX) / (maxX - minX) * (D.width - 2 * inset)); int y = (int) ((p.y - minY) / (maxY - minY) * (D.height - 2.0 * inset)); if (p.diameter > 1) { int r = p.diameter / 2; g.fillOval(inset + x - r, D.height - y - inset - r, 2 * r, 2 * r); } else { g.fillRect(inset + x, D.height - y - inset, 1, 1); } }
private void drawPlayers(Graphics g) { Iterator i = players.iterator(); Player p; while (i.hasNext()) { p = (Player) i.next(); if (p.isActive()) { if (p.getImmunity()) { g.setColor(Color.red.brighter()); g.drawOval(p.getX() - 30, p.getY() - 30, 60, 60); } g.setColor(Color.WHITE); g.fillOval(p.getX() - 5, p.getY() - 5, 10, 10); } p.paint(g); } }
public void draw(Graphics g) { Color color = strokeColor != null ? strokeColor : ROIColor; if (fillColor != null) color = fillColor; g.setColor(color); mag = getMagnification(); int sw = (int) (width * mag); int sh = (int) (height * mag); int sw2 = (int) (0.14645 * width * mag); int sh2 = (int) (0.14645 * height * mag); int sx1 = screenX(x); int sy1 = screenY(y); int sx2 = sx1 + sw / 2; int sy2 = sy1 + sh / 2; int sx3 = sx1 + sw; int sy3 = sy1 + sh; Graphics2D g2d = (Graphics2D) g; if (stroke != null) g2d.setStroke(getScaledStroke()); if (fillColor != null) g.fillOval(sx1, sy1, sw, sh); else g.drawOval(sx1, sy1, sw, sh); if (state != CONSTRUCTING && clipboard == null && !overlay) { int size2 = HANDLE_SIZE / 2; drawHandle(g, sx1 + sw2 - size2, sy1 + sh2 - size2); drawHandle(g, sx3 - sw2 - size2, sy1 + sh2 - size2); drawHandle(g, sx3 - sw2 - size2, sy3 - sh2 - size2); drawHandle(g, sx1 + sw2 - size2, sy3 - sh2 - size2); drawHandle(g, sx2 - size2, sy1 - size2); drawHandle(g, sx3 - size2, sy2 - size2); drawHandle(g, sx2 - size2, sy3 - size2); drawHandle(g, sx1 - size2, sy2 - size2); } drawPreviousRoi(g); if (updateFullWindow) { updateFullWindow = false; imp.draw(); } if (state != NORMAL) showStatus(); }
/*.................................................................................................................*/ public Object doCommand(String commandName, String arguments, CommandChecker checker) { Tree trt = treeDisplay.getTree(); MesquiteTree t = null; if (trt instanceof MesquiteTree) t = (MesquiteTree) trt; if (checker.compare( this.getClass(), "Adjust tool has touched branch", "[branch number][x coordinate touched][y coordinate touched][modifiers]", commandName, "touchedPositionAdjust")) { if (t == null) return null; MesquiteInteger io = new MesquiteInteger(0); int node = MesquiteInteger.fromString(arguments, io); int x = MesquiteInteger.fromString(arguments, io); int y = MesquiteInteger.fromString(arguments, io); String mod = ParseUtil.getRemaining(arguments, io); Point newOnLine = treeDisplay.getTreeDrawing().projectionOnLine(node, x, y); originalX = newOnLine.x; originalY = newOnLine.y; // lastX= newOnLine.x; // lastY = newOnLine.y; Graphics g = null; if (GraphicsUtil.useXORMode(null, false)) { g = treeDisplay.getGraphics(); g.setXORMode(Color.white); g.setColor(Color.red); } // double bX = treeDisplay.getTreeDrawing().lineBaseX[node]; // double bY = treeDisplay.getTreeDrawing().lineBaseY[node]; // Math.sqrt((originalY-bY)*(originalY-bY) + (originalX-bX)*(originalX-bX)); lastBL = tree.getBranchLength(node); double shortestAbove = MesquiteDouble.unassigned; for (int daughter = t.firstDaughterOfNode(node); t.nodeExists(daughter); daughter = t.nextSisterOfNode(daughter)) shortestAbove = MesquiteDouble.minimum(shortestAbove, tree.getBranchLength(daughter)); if (shortestAbove == MesquiteDouble.unassigned) upperLimit = MesquiteDouble.infinite; else if (MesquiteDouble.isCombinable(lastBL)) upperLimit = shortestAbove + lastBL; else upperLimit = shortestAbove + 1.0; int ibX = treeDisplay.getTreeDrawing().lineBaseX[node]; int ibY = treeDisplay.getTreeDrawing().lineBaseY[node]; lastX = treeDisplay.getTreeDrawing().lineTipX[node]; lastY = treeDisplay.getTreeDrawing().lineTipY[node]; if (GraphicsUtil.useXORMode(null, false)) { drawThickLine(g, ibX, ibY, lastX, lastY); for (int daughter = t.firstDaughterOfNode(node); t.nodeExists(daughter); daughter = t.nextSisterOfNode(daughter)) drawThickLine( g, treeDisplay.getTreeDrawing().lineTipX[daughter], treeDisplay.getTreeDrawing().lineTipY[daughter], lastX, lastY); g.fillOval( lastX - ovalRadius, lastY - ovalRadius, ovalRadius + ovalRadius, ovalRadius + ovalRadius); try { g.drawString(MesquiteDouble.toString(lastBL), lastX + 10, lastY); } catch (InternalError e) { // workaround for bug on windows java 1.7. } catch (Throwable e) { } lineOn = true; g.dispose(); } } else if (checker.compare( this.getClass(), "Adjust tool has been dropped", "[branch number][x coordinate dropped][y coordinate dropped]", commandName, "droppedPositionAdjust")) { if (t == null) return null; if (editorOn) return null; MesquiteInteger io = new MesquiteInteger(0); int node = MesquiteInteger.fromString(arguments, io); int x = MesquiteInteger.fromString(arguments, io); int y = MesquiteInteger.fromString(arguments, io); if (lineOn) { Point newOnLine = treeDisplay.getTreeDrawing().projectionOnLine(node, x, y); double bX = treeDisplay.getTreeDrawing().lineBaseX[node]; double bY = treeDisplay.getTreeDrawing().lineBaseY[node]; double tX = treeDisplay.getTreeDrawing().lineTipX[node]; double tY = treeDisplay.getTreeDrawing().lineTipY[node]; double lengthLine = Math.sqrt((originalY - bY) * (originalY - bY) + (originalX - bX) * (originalX - bX)); double bL; if (lengthLine != 0) { double extension = Math.sqrt( (newOnLine.y - bY) * (newOnLine.y - bY) + (newOnLine.x - bX) * (newOnLine.x - bX)) / lengthLine; if (t.getBranchLength(node) == 0 || t.branchLengthUnassigned(node)) bL = extension; else bL = t.getBranchLength(node) * extension; } else bL = 1; if (bL > upperLimit) bL = upperLimit; else if (bL < lowerLimit) bL = lowerLimit; double oldBL = t.getBranchLength(node); if (!MesquiteDouble.isCombinable(oldBL)) oldBL = 1.0; t.setBranchLength(node, bL, false); double difference = oldBL - t.getBranchLength(node); for (int daughter = t.firstDaughterOfNode(node); t.nodeExists(daughter); daughter = t.nextSisterOfNode(daughter)) if (MesquiteDouble.isCombinable(t.getBranchLength(daughter))) t.setBranchLength(daughter, t.getBranchLength(daughter) + difference, false); t.notifyListeners(this, new Notification(MesquiteListener.BRANCHLENGTHS_CHANGED)); Graphics g = treeDisplay.getGraphics(); g.setPaintMode(); g.dispose(); treeDisplay.pleaseUpdate(true); lineOn = false; } } else if (checker.compare( this.getClass(), "Adjust tool is being dragged", "[branch number][x coordinate][y coordinate]", commandName, "draggedPositionAdjust")) { if (t == null) return null; if (editorOn) return null; MesquiteInteger io = new MesquiteInteger(0); int node = MesquiteInteger.fromString(arguments, io); int x = MesquiteInteger.fromString(arguments, io); int y = MesquiteInteger.fromString(arguments, io); if (lineOn) { Point newOnLine = treeDisplay.getTreeDrawing().projectionOnLine(node, x, y); // WARNING": This shouldn't result in length increase if simple click and release with no // drag; must subtract original X, Y Graphics g = null; if (GraphicsUtil.useXORMode(null, false)) { g = treeDisplay.getGraphics(); g.setXORMode(Color.white); g.setColor(Color.red); } // g.fillOval(lastX-ovalRadius, lastY-ovalRadius, ovalRadius + ovalRadius, ovalRadius + // ovalRadius); // g.fillOval(newOnLine.x-ovalRadius, newOnLine.y -ovalRadius, ovalRadius + ovalRadius, // ovalRadius + ovalRadius); // g.drawLine(originalX, originalY, lastX, lastY); // g.drawLine(originalX, originalY, newOnLine.x, newOnLine.y); // if decreasing, & unassigned involved: push unassigned down and assign values to // unassigned above; if increasing, push unassigne up int ibX = treeDisplay.getTreeDrawing().lineBaseX[node]; int ibY = treeDisplay.getTreeDrawing().lineBaseY[node]; int itX = treeDisplay.getTreeDrawing().lineTipX[node]; int itY = treeDisplay.getTreeDrawing().lineTipY[node]; double bX = ibX; double bY = ibY; double tX = itX; double tY = itY; double lengthLine = Math.sqrt((originalY - bY) * (originalY - bY) + (originalX - bX) * (originalX - bX)); if (lengthLine != 0) { if (GraphicsUtil.useXORMode(null, false)) { if (MesquiteTrunk.isMacOSX() && MesquiteTrunk.getJavaVersionAsDouble() >= 1.5 && MesquiteTrunk.getJavaVersionAsDouble() < 1.6) // due to a JVM bug g.fillRect(lastX, lastY - 20, 100, 20); g.drawString(MesquiteDouble.toString(lastBL), lastX + 10, lastY); if (MesquiteTrunk.isMacOSX() && MesquiteTrunk.getJavaVersionAsDouble() >= 1.5 && MesquiteTrunk.getJavaVersionAsDouble() < 1.6) // due to a JVM bug g.fillRect(lastX, lastY - 20, 100, 20); } double extension = Math.sqrt( (newOnLine.y - bY) * (newOnLine.y - bY) + (newOnLine.x - bX) * (newOnLine.x - bX)) / lengthLine; double bL; if (t.getBranchLength(node) == 0 || t.branchLengthUnassigned(node)) bL = extension; else bL = t.getBranchLength(node) * extension; if (bL > upperLimit) { bL = upperLimit; if (t.getBranchLength(node) == 0 || t.branchLengthUnassigned(node)) extension = upperLimit; else extension = upperLimit / t.getBranchLength(node); } else if (bL < lowerLimit) { bL = lowerLimit; if (t.getBranchLength(node) == 0 || t.branchLengthUnassigned(node)) extension = lowerLimit; else extension = lowerLimit / t.getBranchLength(node); } lastBL = bL; if (GraphicsUtil.useXORMode(null, false)) { drawThickLine(g, ibX, ibY, lastX, lastY); for (int daughter = t.firstDaughterOfNode(node); t.nodeExists(daughter); daughter = t.nextSisterOfNode(daughter)) drawThickLine( g, treeDisplay.getTreeDrawing().lineTipX[daughter], treeDisplay.getTreeDrawing().lineTipY[daughter], lastX, lastY); g.fillOval( lastX - ovalRadius, lastY - ovalRadius, ovalRadius + ovalRadius, ovalRadius + ovalRadius); } int newX = ibX + (int) (extension * (tX - bX)); int newY = ibY + (int) (extension * (tY - bY)); if (GraphicsUtil.useXORMode(null, false)) { g.drawString(MesquiteDouble.toString(bL), newX + 10, newY); drawThickLine(g, ibX, ibY, newX, newY); for (int daughter = t.firstDaughterOfNode(node); t.nodeExists(daughter); daughter = t.nextSisterOfNode(daughter)) drawThickLine( g, treeDisplay.getTreeDrawing().lineTipX[daughter], treeDisplay.getTreeDrawing().lineTipY[daughter], newX, newY); g.fillOval( newX - ovalRadius, newY - ovalRadius, ovalRadius + ovalRadius, ovalRadius + ovalRadius); } lastX = newX; lastY = newY; } // lastX= newOnLine.x; // lastY = newOnLine.y; } } return null; }
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; // for antialising geometric shapes g2d.addRenderingHints( new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); // for antialiasing text g2d.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g.drawImage(this.boardImage, 0, 0, null); if (this.drawGrid) { for (int x = 0; x < 24; x++) { for (int y = 0; y < 29; y++) { g.setColor(Color.RED); g.drawRect( (int) ((x * GUI.xSize) + GUI.xOffset), (int) ((y * GUI.ySize) + GUI.yOffset), (int) GUI.xSize, (int) GUI.ySize); } } } if (ui.chooseMovementsMode) { for (int x = 0; x < 24; x++) { for (int y = 0; y < 29; y++) { if (ui.moveables[x][y] == 1) g.setColor(new Color(0, 255, 0, 60)); else if (ui.moveables[x][y] == 2) g.setColor(new Color(0, 0, 255, 80)); else continue; g.fillRect( (int) Math.ceil((x * GUI.xSize) + GUI.xOffset), (int) Math.ceil((y * GUI.ySize) + GUI.yOffset), (int) Math.ceil(GUI.xSize), (int) Math.ceil(GUI.ySize)); } } } for (Character c : Character.characters) { System.out.printf("%d %d\n", c.X, c.Y); Color targetColour = Color.BLACK; /* * new Character("Kasandra Scarlet", 18, 28), new Character("Jack Mustard", 7, 28), new Character("Diane White", 0, 19), new Character("Jacob Green", 0, 9), new Character("Eleanor Peacock", 20, 0), new Character("Victor Plum", 6, 0) */ if (c == Character.characters[0]) targetColour = scarletColor; else if (c == Character.characters[1]) targetColour = mustardColor; else if (c == Character.characters[2]) targetColour = whiteColor; else if (c == Character.characters[3]) targetColour = greenColor; else if (c == Character.characters[4]) targetColour = peacockColor; else if (c == Character.characters[5]) targetColour = plumColor; g.setColor(targetColour); g.fillOval( GUI.getCoordFromBoardX(c.X) + 2, GUI.getCoordFromBoardY(c.Y) + 2, (int) (GUI.xSize - 4), (int) (GUI.ySize - 4)); g.setColor(Color.BLACK); g.drawOval( GUI.getCoordFromBoardX(c.X) + 2, GUI.getCoordFromBoardY(c.Y) + 2, (int) (GUI.xSize - 4), (int) (GUI.ySize - 4)); } }