java.awt.Graphics2D#fill3DRect ( )源码实例Demo

下面列出了java.awt.Graphics2D#fill3DRect ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dsworkbench   文件: FillingLabel.java
@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    if (fillings == null || colors == null || fillings.length != colors.length) {
        return;
    }
    int h = getHeight() / fillings.length;
    if (h == 0) {
        return;
    }
    for (int i = 0; i < fillings.length; i++) {
        g2d.setColor(colors[i]);
        g2d.fill3DRect(0, i * h, (int) Math.rint(getWidth() * fillings[i]), h, true);
    }
    g2d.setColor(Color.LIGHT_GRAY);
    g2d.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
    g2d.setColor(Color.BLACK);
    g2d.drawString(text, 1, getHeight() - 1);
}
 
源代码2 项目: ontopia   文件: ColouredSquareMenuItem.java
/** Draw a coloured square at the end of the display. */
@Override
public void paintComponent(Graphics g) {
  super.paintComponent(g);

  Graphics2D g2 = (Graphics2D) g;

  Shape clip = g2.getClip();
  Rectangle bounds = clip.getBounds();
  double width = bounds.getWidth();
  double height = bounds.getHeight();

  g2.setColor(squareColor);
  g2.fill3DRect(((int) width - 25), 0, 25, (int) height, true);
  
  visibleIndicator.paintComponent(g);
}
 
源代码3 项目: Girinoscope   文件: GraphPane.java
private void paintThresholdRule(Graphics2D g) {
    g.setColor(THRESHOLD_COLOR);
    Point point = toGraphArea(uMax, threshold);
    Stroke defaultStroke = g.getStroke();
    g.setStroke(DOTTED);
    g.drawLine(point.x, point.y, point.x + graphArea.width, point.y);
    g.setStroke(defaultStroke);

    Graphics2D gg = (Graphics2D) g.create();
    gg.translate(point.x, point.y);
    gg.rotate(Math.PI / 4);
    if (grabbedRule == Rule.THRESHOLD_RULE) {
        gg.fill3DRect(-4, -4, 9, 9, true);
    } else {
        gg.fill3DRect(-3, -3, 7, 7, true);
    }
}
 
源代码4 项目: Girinoscope   文件: GraphPane.java
private void paintWaitDurationRule(Graphics2D g) {
    g.setColor(WAIT_DURATION_COLOR);
    Point point = toGraphArea(waitDuration, vMax);
    Stroke defaultStroke = g.getStroke();
    g.setStroke(DOTTED);
    g.drawLine(point.x, point.y, point.x, point.y + graphArea.height);
    g.setStroke(defaultStroke);

    Graphics2D gg = (Graphics2D) g.create();
    gg.translate(point.x, point.y);
    gg.rotate(Math.PI / 4);
    if (grabbedRule == Rule.WAIT_DURATION_RULE) {
        gg.fill3DRect(-4, -4, 9, 9, true);
    } else {
        gg.fill3DRect(-3, -3, 7, 7, true);
    }
}
 
源代码5 项目: energy2d   文件: GraphRenderer.java
private void centerString(String s, Graphics2D g, int x, int y, Shape[] shapes) {
	int stringWidth = g.getFontMetrics().stringWidth(s);
	if (shapes == arrowButtons) {
		Color oldColor = g.getColor();
		g.setColor(Color.lightGray);
		ySelectButton.setBounds(x - stringWidth / 2 - 20, y - 10, stringWidth + 40, 16);
		g.fill3DRect(ySelectButton.x, ySelectButton.y, ySelectButton.width, ySelectButton.height, true);
		g.setColor(oldColor);
		int x2 = x - stringWidth / 2 - 15;
		arrowButtons[0].reset();
		arrowButtons[0].addPoint(x2 + 10, y - 6);
		arrowButtons[0].addPoint(x2 + 10, y);
		arrowButtons[0].addPoint(x2 + 4, y - 3);
		g.fillPolygon(arrowButtons[0]);
		x2 = x + stringWidth / 2 + 5;
		arrowButtons[1].reset();
		arrowButtons[1].addPoint(x2 + 4, y - 6);
		arrowButtons[1].addPoint(x2 + 4, y);
		arrowButtons[1].addPoint(x2 + 10, y - 3);
		g.fillPolygon(arrowButtons[1]);
	}
	g.drawString(s, x - stringWidth / 2, y);
}
 
源代码6 项目: dsworkbench   文件: ScreenshotSaver.java
@Override
public void run() {
    while (true) {
        if (mScreen != null) {
            try {
                Point2D.Double pos = MapPanel.getSingleton().getCurrentPosition();
                String first = "";
                first = "Zentrum: " + (int) Math.floor(pos.getX()) + "|" + (int) Math.floor(pos.getY());

                BufferedImage result = ImageUtils.createCompatibleBufferedImage(mScreen.getWidth(null), mScreen.getHeight(null), BufferedImage.OPAQUE);
                Graphics2D g2d = (Graphics2D) result.getGraphics();
                g2d.drawImage(mScreen, 0, 0, null);
                g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f));
                FontMetrics fm = g2d.getFontMetrics();
                Rectangle2D firstBounds = fm.getStringBounds(first, g2d);
                String second = "Erstellt mit DS Workbench " + Constants.VERSION + Constants.VERSION_ADDITION;
                Rectangle2D secondBounds = fm.getStringBounds(second, g2d);
                g2d.setColor(Constants.DS_BACK_LIGHT);
                g2d.fill3DRect(0, (int) (result.getHeight() - firstBounds.getHeight() - secondBounds.getHeight() - 9), (int) (secondBounds.getWidth() + 6), (int) (firstBounds.getHeight() + secondBounds.getHeight() + 9), true);
                g2d.setColor(Color.BLACK);
                g2d.drawString(first, 3, (int) (result.getHeight() - firstBounds.getHeight() - secondBounds.getHeight() - firstBounds.getY() - 6));
                g2d.drawString(second, 3, (int) (result.getHeight() - secondBounds.getHeight() - secondBounds.getY() - 3));
                g2d.dispose();
                ImageIO.write(result, mTargetType, fTargetFile);
                DSWorkbenchMainFrame.getSingleton().fireMapShotDoneEvent();
            } catch (Exception e) {
                DSWorkbenchMainFrame.getSingleton().fireMapShotFailedEvent();
            }
            mScreen = null;
        }
        try {
            Thread.sleep(1000);
        } catch (Exception ignored) {
        }
    }
}
 
源代码7 项目: openbd-core   文件: ImageDrawBeveledRect.java
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
	cfImageData im	= getImage( _session, argStruct );
	
	int x	= getNamedIntParam(argStruct, "x", Integer.MIN_VALUE );
	int y	= getNamedIntParam(argStruct, "y", Integer.MIN_VALUE );
	int w	= getNamedIntParam(argStruct, "width", Integer.MIN_VALUE );
	int h	= getNamedIntParam(argStruct, "height", Integer.MIN_VALUE );

	boolean bRaised	= getNamedBooleanParam(argStruct, "raised", false );
	boolean bFilled	= getNamedBooleanParam(argStruct, "filled", false );

	
	if ( x == Integer.MIN_VALUE )
		throwException(_session, "x not specifed" );
	
	if ( y == Integer.MIN_VALUE )
		throwException(_session, "y not specifed" );
	
	if ( w == Integer.MIN_VALUE )
		throwException(_session, "width not specifed" );
	
	if ( h == Integer.MIN_VALUE )
		throwException(_session, "height not specifed" );

	// Perform the operation
	Graphics2D g2 = im.createGraphics();
	
	if ( bFilled ){
		g2.fill3DRect( x, y, w, h, bRaised );	
	}else{
		g2.draw3DRect(x, y, w, h, bRaised );	
	}
	
	im.dispose(g2);
	return cfBooleanData.TRUE;
}
 
源代码8 项目: knopflerfish.org   文件: JSoftGraph.java
void paintBox(Graphics2D g,
              String   s,
              Color    bgCol,
              Color    fgCol,
              int      x,
              int      y,
              double   size,
              int minWidth, int minHeight,
              boolean bCenterX,
              boolean bCenterY) {
  Object oldComp = g.getComposite();
  g.setComposite((AlphaComposite)alphaHalf);

  String[] lines = split(s, "\n");

  int maxCols = 0;
  for(int i = 0; i <lines.length; i++) {
    if(lines[i].length() > maxCols) {
      maxCols = lines[i].length();
    }
  }

  Font font = g.getFont();

  g.setColor(bgCol);

  int w = Math.max(minWidth, font.getSize() * maxCols / 2 + 30);
  int h = Math.max(minHeight, (font.getSize() + 3) * lines.length + 10);

  if(bCenterX) {
    x -= w/2;
  }
  if(bCenterY) {
    y -= h/2;
  }

  g.fill3DRect(x, y,
               w, h,
               true);


  g.setColor(fgCol);

  x += 10;
  y += font.getSize() + 5;

  g.setComposite((AlphaComposite)oldComp);

  for(int i = 0; i <lines.length; i++) {
    int ix = lines[i].indexOf("\t");
    if(ix != -1) {
      g.drawString(lines[i].substring(0, ix),  x, y);
      g.drawString(lines[i].substring(ix + 1), x+font.getSize()*4, y);
    } else {
      g.drawString(lines[i], x, y);
    }
    y += font.getSize() + 3;
  }

}
 
源代码9 项目: whyline   文件: Fill3DRectEvent.java
public void paint(Graphics2D g) {

	g.fill3DRect(getX(), getY(), getWidth(), getHeight(), getRaised());		

}