/** Dessine l'icone de la grille */ protected static void drawGrid(Graphics g, int x, int y, Color c) { g.setColor(c); for (int i = 0; i < TX.length; i++) g.drawLine(TX[i][0] + x, TX[i][2] + y, TX[i][1] + x, TX[i][2] + y); for (int i = 0; i < TY.length; i++) g.drawLine(TY[i][2] + x, TY[i][0] + y, TY[i][2] + x, TY[i][1] + y); }
protected void computeGeometry() { pictHalfWidth = Width.getInt() / 2; pictWidth = pictHalfWidth + pictHalfWidth - 1; pictHeight = Height.getInt(); xLoc = -pictHalfWidth; yLoc = -pictHeight / 2; setFramesPerCycle(pictWidth - 1); setFrameIncrement(FrameIncrement.getInt()); // System.out.println("width = " + pictWidth); // System.out.println(" x = " + xLoc); // System.out.println(" y = " + yLoc); PxlColor[] ramp = AColor.getPxlColor().sinusoidalRampTo(BColor.getPxlColor(), pictHalfWidth); // System.out.println("w=" + (4*pictHalfWidth-1) + ", h=" + pictHeight); int ibWidth = 4 * pictHalfWidth - 1; if ((imageBuffer == null) || (imageBuffer.getWidth() != ibWidth) || (imageBuffer.getHeight() != pictHeight)) { imageBuffer = new BufferedImage(ibWidth, pictHeight, BufferedImage.TYPE_INT_RGB); } Graphics g = imageBuffer.getGraphics(); for (int x = 0; x < pictHalfWidth; x++) { g.setColor(ramp[x].dev()); g.drawLine(x, 0, x, pictHeight - 1); if (x < (pictHalfWidth - 1)) g.drawLine(pictWidth - x - 1, 0, pictWidth - x - 1, pictHeight - 1); if (x > 0) g.drawLine(pictWidth + x - 1, 0, pictWidth + x - 1, pictHeight - 1); if ((x > 0) && (x < (pictHalfWidth - 1))) g.drawLine(4 * pictHalfWidth - 4 - x, 0, 4 * pictHalfWidth - 4 - x, pictHeight - 1); } g.dispose(); BitMapElement p = (BitMapElement) getDisplayElement(pictElement); p.setImage(imageBuffer); p.setLocation(xLoc, yLoc); p.setClipRect(xLoc, yLoc, pictWidth, pictHeight); }
/** Overrides <code>Graphics.drawLine</code>. */ public void drawLine(int x1, int y1, int x2, int y2) { DebugGraphicsInfo info = info(); if (debugLog()) { info() .log( toShortString() + " Drawing line: from " + pointToString(x1, y1) + " to " + pointToString(x2, y2)); } if (isDrawingBuffer()) { if (debugBuffered()) { Graphics debugGraphics = debugGraphics(); debugGraphics.drawLine(x1, y1, x2, y2); 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.drawLine(x1, y1, x2, y2); Toolkit.getDefaultToolkit().sync(); sleep(info.flashTime); } graphics.setColor(oldColor); } graphics.drawLine(x1, y1, x2, y2); }
static void drawActiveButtonBorder(Graphics g, int x, int y, int w, int h) { drawFlush3DBorder(g, x, y, w, h); g.setColor(MetalLookAndFeel.getPrimaryControl()); g.drawLine(x + 1, y + 1, x + 1, h - 3); g.drawLine(x + 1, y + 1, w - 3, x + 1); g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); g.drawLine(x + 2, h - 2, w - 2, h - 2); g.drawLine(w - 2, y + 2, w - 2, h - 2); }
@Override protected void paintContentBorderBottomEdge( Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { if (tabPane.getTabCount() < 1) return; g.setColor(shadow); g.drawLine(x + 1, y + h - 3, x + w - 2, y + h - 3); g.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2); g.setColor(shadow.brighter()); g.drawLine(x + 2, y + h - 1, x + w - 1, y + h - 1); }
static void drawDefaultButtonPressedBorder(Graphics g, int x, int y, int w, int h) { drawPressed3DBorder(g, x + 1, y + 1, w - 1, h - 1); g.translate(x, y); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(0, 0, w - 3, h - 3); g.drawLine(w - 2, 0, w - 2, 0); g.drawLine(0, h - 2, 0, h - 2); g.setColor(MetalLookAndFeel.getControl()); g.drawLine(w - 1, 0, w - 1, 0); g.drawLine(0, h - 1, 0, h - 1); g.translate(-x, -y); }
/** * This draws a variant "Flush 3D Border" It is used for things like active toggle buttons. This * is used rarely. */ static void drawDark3DBorder(Graphics g, int x, int y, int w, int h) { g.translate(x, y); drawFlush3DBorder(g, 0, 0, w, h); g.setColor(MetalLookAndFeel.getControl()); g.drawLine(1, 1, 1, h - 2); g.drawLine(1, 1, w - 2, 1); g.setColor(MetalLookAndFeel.getControlShadow()); g.drawLine(1, h - 2, 1, h - 2); g.drawLine(w - 2, 1, w - 2, 1); g.translate(-x, -y); }
void drawLine(Graphics g, DrawObject L) { if (L == null) { return; } if ((sequencingOn) && (L.sequenceNum != currentSequenceNumDisplay)) { return; } Graphics2D g2 = (Graphics2D) g; g2.setStroke(L.drawStroke); int x1 = (int) ((L.x - minX) / (maxX - minX) * (D.width - 2 * inset)); int y1 = (int) ((L.y - minY) / (maxY - minY) * (D.height - 2.0 * inset)); int x2 = (int) ((L.x2 - minX) / (maxX - minX) * (D.width - 2 * inset)); int y2 = (int) ((L.y2 - minY) / (maxY - minY) * (D.height - 2.0 * inset)); if (L.isArrow) { drawArrow( (Graphics2D) g, inset + x1, D.height - y1 - inset, inset + x2, D.height - y2 - inset, 1.0f, L.drawStroke); } else { g.drawLine(inset + x1, D.height - y1 - inset, inset + x2, D.height - y2 - inset); } }
@Override protected void paintContentBorderTopEdge( Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { if (tabPane.getTabCount() < 1) return; g.setColor(shadow); g.drawLine(x, y, x + w - 2, y); }
static void drawDefaultButtonBorder(Graphics g, int x, int y, int w, int h, boolean active) { drawButtonBorder(g, x + 1, y + 1, w - 1, h - 1, active); g.translate(x, y); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(0, 0, w - 3, h - 3); g.drawLine(w - 2, 0, w - 2, 0); g.drawLine(0, h - 2, 0, h - 2); g.translate(-x, -y); }
/** * Draw a line from {@code p1} to {@code p2} and return {@code p2}. * * <p>Returning {@code p2} supports the client in drawing polylines. * * @param p1 point to draw from * @param p2 point to draw to * @param color color to use for drawing * @return {@code p2} */ public Point drawLine(Point p1, Point p2, Color color) { Graphics g = this.image.getGraphics(); if (color != null) { g.setColor(color); } g.drawLine(p1.x, p1.y, p2.x, p2.y); this.repaint(); return (new Point(p2)); }
/** This draws the "Flush 3D Border" which is used throughout the Metal L&F */ static void drawFlush3DBorder(Graphics g, int x, int y, int w, int h) { g.translate(x, y); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(0, 0, w - 2, h - 2); g.setColor(MetalLookAndFeel.getControlHighlight()); g.drawRect(1, 1, w - 2, h - 2); g.setColor(MetalLookAndFeel.getControl()); g.drawLine(0, h - 1, 1, h - 2); g.drawLine(w - 1, 0, w - 2, 1); g.translate(-x, -y); }
/** Paint it. */ public void paint(Graphics g) { Dimension d = getSize(); g.setColor(Color.black); int xoff = d.width / 3; int yoff = d.height / 3; g.drawLine(xoff, 0, xoff, d.height); g.drawLine(2 * xoff, 0, 2 * xoff, d.height); g.drawLine(0, yoff, d.width, yoff); g.drawLine(0, 2 * yoff, d.width, 2 * yoff); int i = 0; for (int r = 0; r < 3; r++) { for (int c = 0; c < 3; c++, i++) { if ((white & (1 << i)) != 0) { g.drawImage(notImage, c * xoff + 1, r * yoff + 1, this); } else if ((black & (1 << i)) != 0) { g.drawImage(crossImage, c * xoff + 1, r * yoff + 1, this); } } } }
public void paint(Graphics g) { if (histogram != null) { if (os == null) { os = createImage(WIDTH, HEIGHT); osg = os.getGraphics(); osg.setColor(Color.white); osg.fillRect(0, 0, WIDTH, HEIGHT); osg.setColor(Color.gray); for (int i = 0; i < WIDTH; i++) { if (hColors != null) osg.setColor(hColors[i]); osg.drawLine(i, HEIGHT, i, HEIGHT - ((int) (HEIGHT * histogram[i]) / hmax) - 4); } osg.dispose(); } g.drawImage(os, 0, 0, this); } else { g.setColor(Color.white); g.fillRect(0, 0, WIDTH, HEIGHT); } g.setColor(Color.black); g.drawLine(0, HEIGHT - 4, 256, HEIGHT - 4); g.drawRect(0, 0, WIDTH, HEIGHT); g.drawRect((int) minHue, 1, (int) (maxHue - minHue), HEIGHT - 5); }
void drawEngineAt(Graphics g, int x, int y, Integer walk, Integer run, Integer current) { // Move this to a buffered Image final int engineWidth = 128; final int engineHeight = 16; int walkLocation = walk * engineWidth / run; int currentLocation = current * engineWidth / run; if (current <= walk) { g.setColor(java.awt.Color.GREEN); } else { g.setColor(java.awt.Color.ORANGE); } g.fillRect(x, y - 12, currentLocation, 8); g.setColor(java.awt.Color.BLACK); for (int i = 0; i <= run; i++) { int l = i * engineWidth / run; g.drawLine(x + l, y, x + l, y - engineHeight / 2); } g.drawLine(x, y, x, y - engineHeight); g.drawLine(x, y, x + engineWidth, y); g.drawLine(x + engineWidth, y, x + engineWidth, y - engineHeight); g.drawLine(x + walkLocation, y, x + walkLocation, y - engineHeight); g.drawString(run.toString(), x + engineWidth - 4, y - engineHeight - 2); g.drawString(walk.toString(), x + walkLocation - 4, y - engineHeight - 2); g.setFont(new Font("Eurostile", 0, 12)); g.drawString("Speed", x, y - engineHeight - 2); }
@Override protected void paintForeground(Graphics g, JComponent component) { // paint icon (if there is any) paintIcon(g, component); Insets ins = getOutsideInsets(); int w = component.getWidth(); int h = component.getHeight(); // paint knob (if there is any) // TODO colors if (behavior.isShowKnob()) { Insets insets = getInnerInsets(); if (getOrientation().isHorizontal()) { int x = ins.left + insets.left - KNOB_SIZE + 3; int y1 = ins.top + insets.top + 3; int y2 = h - insets.bottom - ins.bottom - 4; g.setColor(Color.WHITE); g.drawLine(x, y1, x, y2); g.drawLine(x, y1, x + 1, y1); g.setColor(Color.DARK_GRAY); g.drawLine(x, y2, x + 1, y2); g.drawLine(x + 1, y1 + 1, x + 1, y2); } else { int y = ins.top + insets.top - KNOB_SIZE + 3; int x1 = ins.left + insets.left + 3; int x2 = w - insets.right - ins.right - 4; g.setColor(Color.WHITE); g.drawLine(x1, y, x2, y); g.drawLine(x1, y, x1, y + 1); g.setColor(Color.DARK_GRAY); g.drawLine(x1 + 1, y + 1, x2, y + 1); g.drawLine(x2, y, x2, y + 1); } } }
private void drawLimb(Graphics g, int x, int y, UserData user, JointType from, JointType to) { com.primesense.nite.SkeletonJoint fromJoint = user.getSkeleton().getJoint(from); com.primesense.nite.SkeletonJoint toJoint = user.getSkeleton().getJoint(to); if (fromJoint.getPositionConfidence() == 0.0 || toJoint.getPositionConfidence() == 0.0) { return; } com.primesense.nite.Point2D<Float> fromPos = mTracker.convertJointCoordinatesToDepth(fromJoint.getPosition()); com.primesense.nite.Point2D<Float> toPos = mTracker.convertJointCoordinatesToDepth(toJoint.getPosition()); // draw it in another color than the use color g.setColor(new Color(mColors[(user.getId() + 1) % mColors.length])); g.drawLine( x + fromPos.getX().intValue(), y + fromPos.getY().intValue(), x + toPos.getX().intValue(), y + toPos.getY().intValue()); }
void drawScribbles(Graphics g) { if ((scribbles == null) || (scribbles.size() == 0)) { return; } DrawObject L = (DrawObject) scribbles.get(0); int scribbleCounter = L.scribbleNum; g.setColor(scribbleColor); ((Graphics2D) g).setStroke(new BasicStroke(2f)); int prevX = L.scribbleX; int prevY = L.scribbleY; for (int i = 1; i < scribbles.size(); i++) { L = (DrawObject) scribbles.get(i); if (L.scribbleNum == scribbleCounter) { // Keep drawing. g.drawLine(prevX, prevY, L.scribbleX, L.scribbleY); prevX = L.scribbleX; prevY = L.scribbleY; } else { scribbleCounter = L.scribbleNum; prevX = L.scribbleX; prevY = L.scribbleY; } } }
/** Dessine l'icone de la grille de polarisation */ protected static void drawPolar(Graphics g, int x, int y, Color c) { g.setColor(c); for (int i = 0; i < TY1.length; i++) g.drawLine(TY1[i][1] + x, TY1[i][0] + y, TY1[i][2] + x, TY1[i][0] + y); }
public void drawThickLine(Graphics g, int fromX, int fromY, int toX, int toY) { g.drawLine(fromX, fromY, toX, toY); g.drawLine(fromX + 1, fromY, toX + 1, toY); g.drawLine(fromX + 2, fromY, toX + 2, toY); }
public void paintComponent(Graphics g) { // We request keyboard focus out here so that we can catch events for locking zoom, etc. requestFocus(); // 3 Images are painted each time. The reason we use images rather than directly drawing // onto the graphics context is that the drawings of one image can be taking place // concurrently with the other using threads into offscreen graphic contexts assoc. // with the respective images. While printing we do the opposite if (setupComplete && currImg != null) { int prevH = getPrev(currImg.imgIdH); int nextH = getNext(currImg.imgIdH); if (blFlag || !timer.isRunning()) { img[prevH].paintStuff1(0, g, this); currImg.paintStuff1(_xPix, g, this); img[nextH].paintStuff1(_xPix + _xPix, g, this); /*g.drawImage (img [prevH].img, 0, 0, this); g.drawImage (img [prevH].timeimg, 0, _yPix, this); g.drawImage (currImg.img, _xPix, 0, this); g.drawImage (currImg.timeimg, _xPix, _yPix, this); g.drawImage (img [nextH].img, _xPix + _xPix, 0, this); g.drawImage (img [nextH].timeimg, _xPix + _xPix, _yPix, this);*/ } else { img[prevH].paintStuff2(0, g, this); currImg.paintStuff2(_xPix, g, this); img[nextH].paintStuff2(_xPix + _xPix, g, this); /*g.drawImage (img [prevH].img1, 0, 0, this); g.drawImage (img [prevH].timeimg, 0, _yPix, this); g.drawImage (currImg.img1, _xPix, 0, this); g.drawImage (currImg.timeimg, _xPix, _yPix, this); g.drawImage (img [nextH].img1, _xPix + _xPix, 0, this); g.drawImage (img [nextH].timeimg, _xPix + _xPix, _yPix, this);*/ } } if (zoomLkLineDispStatus && zXTime >= begTime && zXTime <= endTime) { int xcord = panePosX + getEvtXCord(zXTime - begTime); g.setColor(Color.white); g.drawLine(xcord, 0, xcord, _yPix); g.fillRect(xcord, _yPix - lineSize, zLockStrW + 2, lineSize); g.setColor(Color.black); g.drawRect(xcord, _yPix - lineSize, zLockStrW + 1, lineSize - 1); g.setColor(Color.red); g.drawString("Zoom Lock", xcord + 1, _yPix - fDescent); } if (elTLineDispStatus && elapsedPoint >= begTime && elapsedPoint <= endTime) { int xcord = panePosX + getEvtXCord(elapsedPoint - begTime); g.setColor(Color.white); g.drawLine(xcord, 0, xcord, _yPix); g.fillRect(xcord, _yPix - lineSize, elTimeStrW + 2, lineSize); g.setColor(Color.black); g.drawRect(xcord, _yPix - lineSize, elTimeStrW + 1, lineSize - 1); g.setColor(Color.red); g.drawString("Elapsed Time", xcord + 1, _yPix - fDescent); } }
void drawEqnLine(Graphics g, DrawObject L) { if (L == null) { return; } if ((sequencingOn) && (L.sequenceNum != currentSequenceNumDisplay)) { return; } // First, special cases: if ((L.a == 0) && (L.b == 0)) { return; } double px = 0, py = 0, qx = 0, qy = 0; double leftX = px, rightX = qx, leftY = py, rightY = qy; if (L.a == 0) { // Case 2: a=0 => horizontal line. leftX = minX; rightX = maxX; py = -L.c / L.b; qy = -L.c / L.b; if ((py < minY) || (py > maxY)) { // Cannot display. return; } leftY = rightY = py; } else if (L.b == 0) { // Case 3: b=0 => vertical line. leftX = -L.c / L.a; rightX = -L.c / L.a; leftY = minY; rightY = maxY; if ((leftX < minX) || (leftX > maxX)) { return; } } else { // Case 4: regular. // Note: the line could intersect the drawable region in weird ways. px = (-L.c - L.b * minY) / L.a; qx = (-L.c - L.b * maxY) / L.a; py = (-L.c - L.a * minX) / L.b; qy = (-L.c - L.a * maxX) / L.b; // System.out.println ("px=" + px + " qx=" + qx + " py=" + py + " qy=" + qy); // Find leftmost point to draw. if ((py >= minY) && (py <= maxY)) { // Leftmost point is on the x=minX line. leftX = minX; leftY = py; // System.out.println ("case(a): leftmost on minX-line"); } else { // Leftmost point is not on the x=minX line. // Find leftmost point intersecting with low or high if (px < qx) { leftX = px; leftY = minY; // System.out.println ("case(a.1): on minY-line"); } else { leftX = qx; leftY = maxY; // System.out.println ("case(a.2): on maxY-line"); } } // Now find rightmost point. if ((qy >= minY) && (qy <= maxY)) { // Rightmost point is on the x=maxX line. rightX = maxX; rightY = qy; // System.out.println ("case(b): rightmost on maxX-line"); } else { if (px > qx) { rightX = px; rightY = minY; // System.out.println ("case(b.1): rightmost on minY-line"); } else { rightX = qx; rightY = maxY; // System.out.println ("case(b.1): rightmost on maxY-line"); } } } // System.out.println ("left:(" + leftX + "," + leftY + ") right:(" + rightX + "," + rightY + // ")"); int x1 = (int) ((leftX - minX) / (maxX - minX) * (D.width - 2 * inset)); int y1 = (int) ((leftY - minY) / (maxY - minY) * (D.height - 2.0 * inset)); int x2 = (int) ((rightX - minX) / (maxX - minX) * (D.width - 2 * inset)); int y2 = (int) ((rightY - minY) / (maxY - minY) * (D.height - 2.0 * inset)); Graphics2D g2 = (Graphics2D) g; g2.setStroke(L.drawStroke); g.drawLine(inset + x1, D.height - y1 - inset, inset + x2, D.height - y2 - inset); }
@Override public void paint(Graphics g) { Color origColor; boolean isPressed, isRollOver, isEnabled; int w, h, size; w = getWidth(); h = getHeight(); origColor = g.getColor(); isPressed = getModel().isPressed(); isRollOver = getModel().isRollover(); isEnabled = isEnabled(); g.setColor(getBackground()); g.fillRect(0, 0, w, h); g.setColor(shadow); // Using the background color set above if (direction == WEST) { g.drawLine(0, 0, 0, h - 1); // left g.drawLine(w - 1, 0, w - 1, 0); // right } else g.drawLine(w - 2, h - 1, w - 2, 0); // right g.drawLine(0, 0, w - 2, 0); // top if (isRollOver) { // do highlights or shadows Color color1; Color color2; if (isPressed) { color2 = Color.WHITE; color1 = shadow; } else { color1 = Color.WHITE; color2 = shadow; } g.setColor(color1); if (direction == WEST) { g.drawLine(1, 1, 1, h - 1); // left g.drawLine(1, 1, w - 2, 1); // top g.setColor(color2); g.drawLine(w - 1, h - 1, w - 1, 1); // right } else { g.drawLine(0, 1, 0, h - 1); g.drawLine(0, 1, w - 3, 1); // top g.setColor(color2); g.drawLine(w - 3, h - 1, w - 3, 1); // right } } // g.drawLine(0, h - 1, w - 1, h - 1); //bottom // If there's no room to draw arrow, bail if (h < 5 || w < 5) { g.setColor(origColor); return; } if (isPressed) { g.translate(1, 1); } // Draw the arrow size = Math.min((h - 4) / 3, (w - 4) / 3); size = Math.max(size, 2); boolean highlight = false; if (!highlightedTabs.isEmpty() && ((direction == WEST && tabScroller.scrollBackwardButton.isEnabled()) || (direction == EAST && tabScroller.scrollForwardButton.isEnabled()))) { Rectangle viewRect = tabScroller.viewport.getViewRect(); if (direction == WEST) { int leadingTabIndex = getClosestTab(viewRect.x, viewRect.y); for (int i = 0; i < leadingTabIndex; i++) { if (highlightedTabs.contains(i) && !isScrollTabVisible(i)) { highlight = true; break; } } } else { int leadingTabIndex = getClosestTab(viewRect.x + viewRect.y, viewRect.y); for (int i = leadingTabIndex; i < tabPane.getTabCount(); i++) { if (highlightedTabs.contains(i) && !isScrollTabVisible(i)) { highlight = true; break; } } } if (highlight) { Image img = DesktopUtilActivator.getImage( direction == WEST ? "service.gui.icons.TAB_UNREAD_BACKWARD_ICON" : "service.gui.icons.TAB_UNREAD_FORWARD_ICON"); int wi = img.getWidth(null); g.drawImage(img, (w - wi) / 2, (h - size) / 2 - 2 /* 2 borders 1px width*/, null); } } if (!highlight) paintTriangle(g, (w - size) / 2, (h - size) / 2, size, direction, isEnabled); // Reset the Graphics back to it's original settings if (isPressed) { g.translate(-1, -1); } g.setColor(origColor); }
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; RenderingHints rh = g2d.getRenderingHints(); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHints(rh); // Background. D = this.getSize(); g.setColor(backgroundColor); g.fillRect(0, 0, D.width, D.height); Graphics2D g2 = (Graphics2D) g; g2.setStroke(lineStroke); // Axes, bounding box. g.setColor(Color.gray); g.drawLine(inset, D.height - inset, D.width - inset, D.height - inset); g.drawLine(D.width - inset, inset, D.width - inset, D.height - inset); g.drawLine(inset, inset, inset, D.height - inset); g.drawLine(inset, inset, D.width - inset, inset); double xDelta = (maxX - minX) / numIntervals; // X-ticks and labels. for (int i = 1; i <= numIntervals; i++) { double xTickd = i * xDelta; int xTick = (int) (xTickd / (maxX - minX) * (D.width - 2 * inset)); g.drawLine(inset + xTick, D.height - inset - 5, inset + xTick, D.height - inset + 5); double x = minX + i * xDelta; g.drawString(df.format(x), xTick + inset - 5, D.height - inset + 20); } // Y-ticks double yDelta = (maxY - minY) / numIntervals; for (int i = 0; i < numIntervals; i++) { int yTick = (i + 1) * (int) ((D.height - 2 * inset) / (double) numIntervals); g.drawLine(inset - 5, D.height - yTick - inset, inset + 5, D.height - yTick - inset); double y = minY + (i + 1) * yDelta; g.drawString(df.format(y), 1, D.height - yTick - inset); } // Zoom+move Font savedFont = g.getFont(); g.setFont(plusFont); g.drawString("+", D.width - 25, 20); g.setFont(minusFont); g.drawString("-", D.width - 25, 50); drawArrow(g2d, D.width - 70, 20, D.width - 70, 0, 1.0f, lineStroke); // Up drawArrow(g2d, D.width - 70, 30, D.width - 70, 50, 1.0f, lineStroke); // Down drawArrow(g2d, D.width - 65, 25, D.width - 45, 25, 1.0f, lineStroke); // Right drawArrow(g2d, D.width - 75, 25, D.width - 95, 25, 1.0f, lineStroke); // Left g.setFont(savedFont); // See if standard axes are in the middle. g.setColor(Color.gray); if ((minX < 0) && (maxX > 0) && (drawMiddleAxes)) { // Draw y-axis int x = (int) ((0 - minX) / (maxX - minX) * (D.width - 2 * inset)); g.drawLine(inset + x, D.height - inset, inset + x, inset); } if ((minY < 0) && (maxY > 0) && (drawMiddleAxes)) { // Draw x-axis int y = (int) ((0 - minY) / (maxY - minY) * (D.height - 2.0 * inset)); g.drawLine(inset, D.height - y - inset, D.width - inset, D.height - y - inset); } // Draw the objects. drawObjects(g, points, lines, ovals, rectangles, images, labels, eqnLines); if (animationMode) { drawObjects(g, animPoints, animLines, animOvals, animRectangles, null, labels, eqnLines); // No images in animation mode. } drawScribbles(g); }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("image/jpeg"); pageContext = _jspxFactory.getPageContext( this, request, response, "/myhtml/errorpage/erroe.jsp", true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n"); out.write("\r\n"); out.write('\r'); out.write('\n'); // 设置页é¢ä¸ç¼å response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); // å¨å åä¸å建å¾è±¡ int width = 60, height = 20; BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // è·åå¾å½¢ä¸ä¸æ Graphics g = image.getGraphics(); // çæéæºç±» Random random = new Random(); // 设å®èæ¯è² g.setColor(getRandColor(200, 250)); g.fillRect(0, 0, width, height); // 设å®åä½ g.setFont(new Font("Times New Roman", Font.PLAIN, 18)); // ç»è¾¹æ¡ // g.setColor(new Color()); // g.drawRect(0,0,width-1,height-1); // éæºäº§ç155æ¡å¹²æ°çº¿ï¼ä½¿å¾è±¡ä¸ç认è¯ç ä¸æè¢«å ¶å®ç¨åºæ¢æµå° g.setColor(getRandColor(160, 200)); for (int i = 0; i < 155; i++) { int x = random.nextInt(width); int y = random.nextInt(height); int xl = random.nextInt(12); int yl = random.nextInt(12); g.drawLine(x, y, x + xl, y + yl); } // åéæºäº§çç认è¯ç (4ä½æ°å) String sRand = ""; for (int i = 0; i < 4; i++) { String rand = String.valueOf(random.nextInt(10)); sRand += rand; // å°è®¤è¯ç æ¾ç¤ºå°å¾è±¡ä¸ g.setColor( new Color( 20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110))); // è°ç¨å½æ°åºæ¥çé¢è²ç¸åï¼å¯è½æ¯å // 为ç§å太æ¥è¿ï¼æ以åªè½ç´æ¥çæ g.drawString(rand, 13 * i + 6, 16); } // å°è®¤è¯ç åå ¥SESSION session.setAttribute("rand", sRand); // å¾è±¡çæ g.dispose(); // è¾åºå¾è±¡å°é¡µé¢ ImageIO.write(image, "JPEG", response.getOutputStream()); out.clear(); out = pageContext.pushBody(); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else log(t.getMessage(), t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
/** Dessine l'icone d'un SED */ protected static void drawSED(Graphics g, int x, int y, Color c) { g.setColor(c); for (int i = 0; i < SY2.length; i++) g.drawLine(SY2[i][0] + x, SY2[i][2] + y, SY2[i][1] + x, SY2[i][2] + y); }
/** Dessine lle fond de l'icone de la grille d'un MOC */ protected static void fillMOC(Graphics g, int x, int y, Color c) { g.setColor(c); for (int i = 0; i < TY2BG.length; i++) g.drawLine(TY2BG[i][0] + x, TY2BG[i][2] + y, TY2BG[i][1] + x, TY2BG[i][2] + y); }
private void drawLayout(Graphics g) { g.setColor(Color.blue); g.drawRect(10, 10, width - 20, height - 20); g.setColor(Color.red.brighter()); Iterator f = players.iterator(); int lifeDisplayPosition = 0; while (f.hasNext()) { Player h = (Player) f.next(); if (h.isActive()) { lifeDisplayPosition++; String lifeInformation = "Player " + lifeDisplayPosition + ": "; for (int i = 0; i < h.getLives(); i++) { lifeInformation += "\u2606"; } g.drawString(lifeInformation, 20, lifeDisplayPosition * 40); } } borders[2] = width - 20; borders[3] = height - 20; Iterator i = players.iterator(); Player p; while (i.hasNext()) { p = (Player) i.next(); if (p.isActive() && !countdownF && (p.getX() < borders[0] || p.getY() < borders[1] || p.getX() > borders[2] || p.getY() > borders[3]) && (!p.getImmunity())) { p.decLives(width / 2, height / 2); p.setImmunity(true); } if (p.getLives() <= 0) { if (p instanceof MouseControlledPlayer) { MouseControlledPlayer m = (MouseControlledPlayer) p; removeMouseListener(m); removeMouseMotionListener(m); } else if (p instanceof KeyboardControlledPlayer) { KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher((KeyboardControlledPlayer) p); } i.remove(); for (int h = 0; h < 4; h++) { if (deathLocation[h] == -1) { deathLocation[h] = p.getX(); deathLocation[h + 1] = p.getY(); break; } } } } if ((deathLocation[0] != -1) && (deathLocation[1] != -1)) { g.drawLine( deathLocation[0] - 15, deathLocation[1] - 15, deathLocation[0] + 15, deathLocation[1] + 15); g.drawLine( deathLocation[0] + 15, deathLocation[1] - 15, deathLocation[0] - 15, deathLocation[1] + 15); } if ((deathLocation[2] != -1) && (deathLocation[3] != -1)) { g.drawLine( deathLocation[2] - 15, deathLocation[3] - 15, deathLocation[2] + 15, deathLocation[3] + 15); g.drawLine( deathLocation[2] + 15, deathLocation[3] - 15, deathLocation[2] - 15, deathLocation[3] + 15); } if (!onePlayerAlive) { Font old = g.getFont(); g.setFont(new Font("monospaced", Font.BOLD, 20)); g.setColor(Color.red.darker()); g.drawString("GAME OVER", width / 2 - 40, height / 2); g.setFont(old); g.setColor(Color.WHITE); g.drawString("Score", width - 60, 25); g.drawString(String.valueOf(score), width - 60, 40); } }