当前位置: 首页>>代码示例>>Java>>正文


Java Graphics2D.getClipBounds方法代码示例

本文整理汇总了Java中java.awt.Graphics2D.getClipBounds方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics2D.getClipBounds方法的具体用法?Java Graphics2D.getClipBounds怎么用?Java Graphics2D.getClipBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics2D的用法示例。


在下文中一共展示了Graphics2D.getClipBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawOperator

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the given {@link Operator} if inside the graphics clip bounds.
 *
 * @param op
 *            the operator to draw. Note that it must have a position attached, see
 *            {@link GUIProcessXMLFilter}
 * @param drawPorts
 *            if {@true} will also draw operator ports, otherwise will not draw ports
 * @param g2
 *            the graphics context to draw upon
 * @param printing
 *            if {@code true} we are printing instead of drawing to the screen
 *
 */
public void drawOperator(final Operator op, final boolean drawPorts, final Graphics2D g2, final boolean printing) {
	Rectangle2D frame = model.getOperatorRect(op);
	if (frame == null) {
		return;
	}

	// only draw operator if visible
	Rectangle2D opBounds = new Rectangle2D.Double(frame.getX() - 10, frame.getY(), frame.getWidth() + 20,
			frame.getHeight());
	if (g2.getClipBounds() != null && !g2.getClipBounds().intersects(opBounds)) {
		return;
	}

	renderOperator(op, g2);
	renderPorts(op.getInputPorts(), g2, op.isEnabled());
	renderPorts(op.getOutputPorts(), g2, op.isEnabled());

	// let operator decorators draw
	drawOperatorDecorators(op, g2, printing);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:35,代码来源:ProcessDrawer.java

示例2: drawOperatorBackgrounds

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws operator backgrounds and then calls all registered {@link ProcessDrawDecorator}s for
 * the annotations render phase.
 *
 * @param process
 *            the process to draw the operator backgrounds for
 * @param g2
 *            the graphics context to draw upon
 * @param printing
 *            if {@code true} we are printing instead of drawing to the screen
 */
public void drawOperatorBackgrounds(final ExecutionUnit process, final Graphics2D g2, final boolean printing) {
	Graphics2D gBG = (Graphics2D) g2.create();
	// draw background of operators
	for (Operator op : process.getOperators()) {
		Rectangle2D frame = model.getOperatorRect(op);
		if (frame == null) {
			continue;
		}

		// only draw background if operator is visisble
		Rectangle2D opBounds = new Rectangle2D.Double(frame.getX() - 10, frame.getY(), frame.getWidth() + 20,
				frame.getHeight());
		if (g2.getClipBounds() != null && !g2.getClipBounds().intersects(opBounds)) {
			continue;
		}

		renderOperatorBackground(op, gBG);
	}

	// draw connections background for all operators
	for (Operator operator : process.getOperators()) {
		renderConnectionsBackground(operator.getInputPorts(), operator.getOutputPorts(), gBG);
	}

	// draw connections background for process
	renderConnectionsBackground(process.getInnerSinks(), process.getInnerSources(), gBG);
	gBG.dispose();

	// let decorators draw
	drawPhaseDecorators(process, g2, RenderPhase.OPERATOR_BACKGROUND, printing);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:43,代码来源:ProcessDrawer.java

示例3: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paint(Graphics2D g, StateColorMap colorMap) {
  Rectangle bounds = g.getClipBounds();
  if (startY > bounds.getMaxY() || startY + height < bounds.getMinY()) {
    return;
  }

  int x = line.getX();
  int width = line.getWidth();

  Color color = colorMap.getColor(stateName);
  g.setColor(color);
  g.fillRoundRect(x, startY, width, height, ARC_SIZE, ARC_SIZE);
  g.setColor(Color.BLACK);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:LifelineState.java

示例4: highlight

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void highlight(Graphics2D g) {
  Rectangle bounds = g.getClipBounds();
  if (startY > bounds.getMaxY() || startY + height < bounds.getMinY()) {
    return;
  }

  int x = line.getX();
  int width = line.getWidth();

  g.drawRoundRect(x, startY, width, height, ARC_SIZE, ARC_SIZE);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:12,代码来源:LifelineState.java

示例5: test

import java.awt.Graphics2D; //导入方法依赖的package包/类
private static void test(final Graphics2D g) {
    for (final Shape clip : clips) {
        g.setClip(clip);
        if (!g.getClip().equals(clip)) {
            System.err.println("Expected clip: " + clip);
            System.err.println("Actual clip: " + g.getClip());
            System.err.println("bounds="+g.getClip().getBounds2D());
            System.err.println("bounds="+g.getClip().getBounds());
            status = false;
        }
        final Rectangle bounds = g.getClipBounds();
        if (!clip.equals(bounds)) {
            System.err.println("Expected getClipBounds(): " + clip);
            System.err.println("Actual getClipBounds(): " + bounds);
            status = false;
        }
        g.getClipBounds(bounds);
        if (!clip.equals(bounds)) {
            System.err.println("Expected getClipBounds(r): " + clip);
            System.err.println("Actual getClipBounds(r): " + bounds);
            status = false;
        }
        if (!clip.getBounds2D().isEmpty() && ((SunGraphics2D) g).clipRegion
                .isEmpty()) {
            System.err.println("clipRegion should not be empty");
            status = false;
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:Test8004859.java

示例6: paintBase

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintBase(Graphics2D g) {
    if (endOFF) {
        return;
    }
    setArea(null);
    Rectangle r = this.getBounds();
    g.setColor(Color.GRAY);
    g.drawRoundRect(0, 0, r.width - 1, r.height - 1, 10, 10);

    g.setColor(Color.lightGray);
    g.drawRoundRect(5, 5, r.height - 10, r.height - 10, 4,4);

    int met = (r.height - 11) / 2;
    g.setColor(Color.black);
    g.drawLine(7, 6 + met, r.height - 7, 6 + met);
    if ('+' == getEstado()) {
        g.drawLine(6 + met, 7, 6 + met, r.height - 7);
    }

    g.setColor(Color.BLACK);
    Rectangle bkp = g.getClipBounds();
    g.clipRect(0, 0, r.width - 1, r.height);
    if (isSelecionado()) {
        g.setFont(new Font(this.getFont().getFontName(), Font.BOLD, getFont().getSize()));
        g.drawRoundRect(0, 0, r.width - 1, r.height - 1, 10, 10);
    }
    int tmp = (r.width - g.getFontMetrics().stringWidth(getTexto())) / 2;

    g.drawString(getTexto(), tmp, (int) (r.height * 0.72));
    g.setClip(bkp);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:33,代码来源:InspectorItemSeparador.java

示例7: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void draw( Graphics2D g ) {
	Rectangle area = g.getClipBounds();
	currentPoint = null;
	if( !intersects(area) ) return;
	Color color = g.getColor();
	g.setColor( offColor);
	GeneralPath path = new GeneralPath();
	float offset = (float)this.offset;
	for( int seg=0 ; seg<cptIndex.length ; seg++ ) {
		path.moveTo( offset+cptX[seg][0], cptY[seg][0] );
		for( int i=0 ; i<cptIndex[seg].length ; i++ ) {
			path.lineTo( offset+cptX[seg][i], cptY[seg][i] );
		}
	}
	g.draw(path);
	double wrap = map.getWrap();
	if(wrap>0) {
		AffineTransform xform = g.getTransform();
		offset += (float)wrap;
		while( mapBounds.getX()+(double)offset < area.getX()+area.getWidth() ) {
			g.translate( (double)wrap, 0.d );
			g.draw(path);
			offset += (float)wrap;
		}
		g.setTransform( xform );
	}
	g.setColor( onColor );
	drawCurrentSeg(g, true);
	g.setColor( color );
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:31,代码来源:ShipData.java

示例8: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void draw( Graphics2D g ) {
	Rectangle area = g.getClipBounds();
	currentPoint = null;
	if( !intersects(area) ) return;
	Color color = g.getColor();
	g.setColor( OFF_COLOR );
	GeneralPath path = new GeneralPath();
	float offset = (float)this.offset;
	for( int seg=0 ; seg<cptIndex.length ; seg++ ) {
		path.moveTo( offset+cptX[seg][0], cptY[seg][0] );
		for( int i=0 ; i<cptIndex[seg].length ; i++ ) {
			path.lineTo( offset+cptX[seg][i], cptY[seg][i] );
		}
	}
	g.draw(path);
	double wrap = map.getWrap();
	if(wrap>0) {
		AffineTransform xform = g.getTransform();
		offset += (float)wrap;
		while( mapBounds.getX()+(double)offset < area.getX()+area.getWidth() ) {
			g.translate( (double)wrap, 0.d );
			g.draw(path);
			offset += (float)wrap;
		}
		g.setTransform( xform );
	}
	g.setColor( ON_COLOR );
	drawCurrentSeg(g, true);
	g.setColor( color );
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:31,代码来源:MGGData.java

示例9: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {

    if (!(g instanceof Graphics2D)) {
        return;
    }

    int width = getWidth();
    int barRectWidth = width;
    int height = getHeight();
    int barRectHeight = height;

    if (barRectWidth <= 0 || barRectHeight <= 0) {
        return;
    }

    int amountFull = (int) (barRectWidth * coveragePercentage / 100.0f);

    Graphics2D g2 = (Graphics2D) g;

    g2.setColor(getBackground());

    Color notCoveredLight = NOT_COVERED_LIGHT;
    Color notCoveredDark = NOT_COVERED_DARK;
    Color coveredLight = COVERED_LIGHT;
    Color coveredDark = COVERED_DARK;
    if (emphasize) {
        coveredDark = coveredDark.darker();
    } else if (selected) {
        coveredLight = coveredLight.brighter();
        coveredDark = coveredDark.darker();
    }
    if (emphasize) {
        notCoveredDark = notCoveredDark.darker();
    } else if (selected) {
        notCoveredLight = notCoveredLight.brighter();
        notCoveredDark = notCoveredDark.darker();
    }

    g2.setPaint(new GradientPaint(0, 0, notCoveredLight,
            0, height / 2, notCoveredDark));
    g2.fillRect(amountFull, 1, width - 1, height / 2);
    g2.setPaint(new GradientPaint(0, height / 2, notCoveredDark,
            0, 2 * height, notCoveredLight));
    g2.fillRect(amountFull, height / 2, width - 1, height / 2);

    g2.setColor(getForeground());

    g2.setPaint(new GradientPaint(0, 0, coveredLight,
            0, height / 2, coveredDark));
    g2.fillRect(1, 1, amountFull, height / 2);
    g2.setPaint(new GradientPaint(0, height / 2, coveredDark,
            0, 2 * height, coveredLight));
    g2.fillRect(1, height / 2, amountFull, height / 2);

    Rectangle oldClip = g2.getClipBounds();
    if (coveragePercentage > 0.0f) {
        g2.setColor(coveredDark);
        g2.clipRect(0, 0, amountFull + 1, height);
        g2.drawRect(0, 0, width - 1, height - 1);
    }
    if (coveragePercentage < 100.0f) {
        g2.setColor(notCoveredDark);
        g2.setClip(oldClip);
        g2.clipRect(amountFull, 0, width, height);
        g2.drawRect(0, 0, width - 1, height - 1);
    }
    g2.setClip(oldClip);

    g2.setFont(getFont());
    paintDropShadowText(g2, barRectWidth, barRectHeight);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:73,代码来源:CoverageBar.java

示例10: paintShape

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * 
 */
public void paintShape(mxGraphics2DCanvas canvas, String text,
		mxCellState state, Map<String, Object> style)
{
	mxLightweightLabel textRenderer = mxLightweightLabel
			.getSharedInstance();
	CellRendererPane rendererPane = canvas.getRendererPane();
	Rectangle rect = state.getLabelBounds().getRectangle();
	Graphics2D g = canvas.getGraphics();

	if (textRenderer != null
			&& rendererPane != null
			&& (g.getClipBounds() == null || g.getClipBounds().intersects(
					rect)))
	{
		double scale = canvas.getScale();
		int x = rect.x;
		int y = rect.y;
		int w = rect.width;
		int h = rect.height;

		if (!mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true))
		{
			g.rotate(-Math.PI / 2, x + w / 2, y + h / 2);
			g.translate(w / 2 - h / 2, h / 2 - w / 2);

			int tmp = w;
			w = h;
			h = tmp;
		}

		// Replaces the linefeeds with BR tags
		if (isReplaceHtmlLinefeeds())
		{
			text = text.replaceAll("\n", "<br>");
		}

		// Renders the scaled text
		textRenderer.setText(createHtmlDocument(style, text,
				(int) Math.round(w / state.getView().getScale()),
				(int) Math.round(h / state.getView().getScale())));
		textRenderer.setFont(mxUtils.getFont(style, canvas.getScale()));
		g.scale(scale, scale);
		rendererPane.paintComponent(g, textRenderer, rendererPane,
				(int) (x / scale) + mxConstants.LABEL_INSET,
				(int) (y / scale) + mxConstants.LABEL_INSET,
				(int) (w / scale), (int) (h / scale), true);
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:52,代码来源:mxHtmlTextShape.java

示例11: paintShape

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * 
 */
public void paintShape(mxGraphics2DCanvas canvas, String text,
		mxCellState state, Map<String, Object> style)
{
	Rectangle rect = state.getLabelBounds().getRectangle();
	Graphics2D g = canvas.getGraphics();

	if (labelGlyphs == null)
	{
		updateLabelBounds(text, style);
	}

	if (labelGlyphs != null
			&& (g.getClipBounds() == null || g.getClipBounds().intersects(
					rect)))
	{
		// Creates a temporary graphics instance for drawing this shape
		float opacity = mxUtils.getFloat(style, mxConstants.STYLE_OPACITY,
				100);
		Graphics2D previousGraphics = g;
		g = canvas.createTemporaryGraphics(style, opacity, state);

		Font font = mxUtils.getFont(style, canvas.getScale());
		g.setFont(font);

		Color fontColor = mxUtils.getColor(style,
				mxConstants.STYLE_FONTCOLOR, Color.black);
		g.setColor(fontColor);

		g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
				RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

		g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
				FONT_FRACTIONALMETRICS);

		for (int j = 0; j < labelGlyphs.length; j++)
		{
			mxLine parallel = labelGlyphs[j].glyphGeometry;

			if (labelGlyphs[j].visible && parallel != null
					&& parallel != mxCurve.INVALID_POSITION)
			{
				mxPoint parallelEnd = parallel.getEndPoint();
				double x = parallelEnd.getX();
				double rotation = (Math.atan(parallelEnd.getY() / x));

				if (x < 0)
				{
					// atan only ranges from -PI/2 to PI/2, have to offset
					// for negative x values
					rotation += Math.PI;
				}

				final AffineTransform old = g.getTransform();
				g.translate(parallel.getX(), parallel.getY());
				g.rotate(rotation);
				Shape letter = labelGlyphs[j].glyphShape;
				g.fill(letter);
				g.setTransform(old);
			}
		}

		g.dispose();
		g = previousGraphics;
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:69,代码来源:mxCurveLabelShape.java

示例12: paintShape

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * 
 */
public void paintShape(mxGraphics2DCanvas canvas, String text, mxCellState state,
    Map<String, Object> style) {
  mxLightweightLabel textRenderer = mxLightweightLabel.getSharedInstance();
  CellRendererPane rendererPane = canvas.getRendererPane();
  Rectangle rect = state.getLabelBounds().getRectangle();
  Graphics2D g = canvas.getGraphics();

  if (textRenderer != null && rendererPane != null
      && (g.getClipBounds() == null || g.getClipBounds().intersects(rect))) {
    double scale = canvas.getScale();
    int x = rect.x;
    int y = rect.y;
    int w = rect.width;
    int h = rect.height;

    if (!mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true)) {
      g.rotate(-Math.PI / 2, x + w / 2, y + h / 2);
      g.translate(w / 2 - h / 2, h / 2 - w / 2);

      int tmp = w;
      w = h;
      h = tmp;
    }

    // Replaces the linefeeds with BR tags
    if (isReplaceHtmlLinefeeds()) {
      text = text.replaceAll("\n", "<br>");
    }

    // Renders the scaled text
    textRenderer
        .setText(createHtmlDocument(style, text, (int) Math.round(w / state.getView().getScale()),
            (int) Math.round(h / state.getView().getScale())));
    textRenderer.setFont(mxUtils.getFont(style, canvas.getScale()));
    g.scale(scale, scale);
    rendererPane.paintComponent(g, textRenderer, rendererPane,
        (int) (x / scale) + mxConstants.LABEL_INSET, (int) (y / scale) + mxConstants.LABEL_INSET,
        (int) (w / scale), (int) (h / scale), true);
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:44,代码来源:mxHtmlTextShape.java

示例13: paintShape

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * 
 */
public void paintShape(mxGraphics2DCanvas canvas, String text, mxCellState state,
    Map<String, Object> style) {
  Rectangle rect = state.getLabelBounds().getRectangle();
  Graphics2D g = canvas.getGraphics();

  if (labelGlyphs == null) {
    updateLabelBounds(text, style);
  }

  if (labelGlyphs != null && (g.getClipBounds() == null || g.getClipBounds().intersects(rect))) {
    // Creates a temporary graphics instance for drawing this shape
    float opacity = mxUtils.getFloat(style, mxConstants.STYLE_OPACITY, 100);
    Graphics2D previousGraphics = g;
    g = canvas.createTemporaryGraphics(style, opacity, state);

    Font font = mxUtils.getFont(style, canvas.getScale());
    g.setFont(font);

    Color fontColor = mxUtils.getColor(style, mxConstants.STYLE_FONTCOLOR, Color.black);
    g.setColor(fontColor);

    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, FONT_FRACTIONALMETRICS);

    for (int j = 0; j < labelGlyphs.length; j++) {
      mxLine parallel = labelGlyphs[j].glyphGeometry;

      if (labelGlyphs[j].visible && parallel != null && parallel != mxCurve.INVALID_POSITION) {
        mxPoint parallelEnd = parallel.getEndPoint();
        double x = parallelEnd.getX();
        double rotation = (Math.atan(parallelEnd.getY() / x));

        if (x < 0) {
          // atan only ranges from -PI/2 to PI/2, have to offset
          // for negative x values
          rotation += Math.PI;
        }

        final AffineTransform old = g.getTransform();
        g.translate(parallel.getX(), parallel.getY());
        g.rotate(rotation);
        Shape letter = labelGlyphs[j].glyphShape;
        g.fill(letter);
        g.setTransform(old);
      }
    }

    g.dispose();
    g = previousGraphics;
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:57,代码来源:mxCurveLabelShape.java

示例14: paintBase

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
    protected void paintBase(Graphics2D g) {
        Rectangle r = this.getBounds();
        int esq = (int) (r.width * Criador.getDivisor());
        setArea(new Rectangle(esq -2, 0, 4, r.height - 1));

        //int dir = r.width - esq;
        if (!isSelecionado()) {
            g.setColor(Color.GRAY);
            g.drawRoundRect(0, 0, r.width - 1, r.height - 1, 10, 10);
            g.drawLine(esq, 0, esq, r.height - 1);

            g.setColor(Color.BLACK);
            
            getCorParaTexto(g);
            
            Rectangle bkp = g.getClipBounds();
            g.clipRect(0, 0, esq - 1, r.height);
            g.drawString(getTexto(), (Criador.espaco * 2) + 1, (int) (r.height * 0.72));

            g.setClip(bkp);
            int re = esq + r.height -5;
            g.setColor(CanEdit() ? Color.BLACK : Color.LIGHT_GRAY);
            g.fillRect(esq + 4, 4, r.height - 9, r.height - 9);
            try {
                Color c = util.Utilidades.StringToColor(getTransValor());//new Color(Integer.parseInt(getTransValor()));
                g.setColor(c);
            } catch (Exception e) {
            }
            Color tmpc = g.getColor();
            String bonito = Integer.toString(tmpc.getRed()) + ", " + Integer.toString(tmpc.getGreen()) + ", " +Integer.toString(tmpc.getBlue())+ ", " +Integer.toString(tmpc.getAlpha());
            
            if (CanEdit()) {
                g.fillRect(esq + 5, 5, r.height - 10, r.height -10);
            }
            
//            g.setColor(CanEdit() ? Color.BLACK : Color.LIGHT_GRAY);
//            g.drawRect(tmp + 4, 4, r.height - 9, r.height -9);
            
            g.clipRect(re, 0, esq - 1, r.height);
            
            getCorParaTexto(g);

            g.drawString(bonito, re + (Criador.espaco * 2) + 1, (int) (r.height * 0.72));

            g.setClip(bkp);

        } else {
            super.paintBase(g);
        }
    }
 
开发者ID:chcandido,项目名称:brModelo,代码行数:52,代码来源:InspectorItemCor.java

示例15: DoPaint

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
    public void DoPaint(Graphics2D g) {
        super.DoPaint(g);
        Rectangle rec = getArea();
        Color bkpc = g.getColor();

        g.setColor(getBorderColor());

        g.drawRect(rec.x, rec.y, rec.width, rec.height);

        Rectangle bkp = g.getClipBounds();
        g.clipRect(rec.x, rec.y, rec.width, rec.height);

        Font fn = getFont();
        Font font = new Font(fn.getFontName(), fn.getStyle(), fn.getSize() - 2);

        fn = g.getFont();
        g.setFont(font);

        altura = g.getFontMetrics().getHeight() + g.getFontMetrics().getDescent();
        alturaTitulo = altura + altura / 2;

        Composite originalComposite = g.getComposite();
        float alfa = 0.8f;
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alfa));

        if (getTipo() == TipoLegenda.tpObjetos) {
            altura = Math.max(32, altura);
        }

        int posi = altura + alturaTitulo + rec.y;
        final int lft = rec.x + 2;

        for (ItemDeLegenda it : getItens()) {

            if (it.isSelecionada()) {
                g.setColor(isDisablePainted()? disabledColor : new Color(204, 204, 255, 50));
                g.fillRect(lft, posi - altura - 2, getWidth(), altura + 4);
            }
            g.setColor(isDisablePainted()? disabledColor : it.cor);
            int moveleft;
            switch (getTipo()) {
                case tpLinhas:
                    moveleft = 3 * altura;
                    g.fillRoundRect(lft, posi - (altura / 2) - 2, moveleft - 2, 4, 2, 2);
                    g.setColor(bkpc);
                    g.drawString(it.texto, lft + moveleft, posi - 6);
                    break;
                case tpObjetos:
                    ImageIcon img = Editor.fromControler().getImagemNormal(getMaster().getCassesDoDiagrama()[it.getTag()].getSimpleName());
                    g.drawImage(util.TratadorDeImagens.ReColorBlackImg(img, it.getCor()), lft, posi - altura, null);
                    moveleft = altura + 2;
                    g.drawString(it.texto, lft + moveleft, posi - altura / 2 + 6);
                    break;
                default:
                    moveleft = altura;
                    g.fillRect(lft, posi - altura, altura - 4, altura - 4);
                    g.setColor(bkpc);
                    g.drawRect(lft, posi - altura, altura - 4, altura - 4);
                    g.drawString(it.texto, lft + moveleft, posi - 6);
            }
            it.Area = new Point(posi - altura - 2, altura + 4);
            posi += altura + 4;
        }

        g.setComposite(originalComposite);

//        g.setColor(Color.LIGHT_GRAY);
//        g.drawLine(lft - 1, posi - altura - 2, getLeft() + getWidth() - 1, posi - altura - 2);
        g.setClip(bkp);
        g.setFont(fn);
    }
 
开发者ID:chcandido,项目名称:brModelo,代码行数:73,代码来源:Legenda.java


注:本文中的java.awt.Graphics2D.getClipBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。