Java Code Examples for java.awt.Graphics2D.getClipBounds()

The following are Jave code examples for showing how to use getClipBounds() of the java.awt.Graphics2D class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: rapidminer   File: ProcessDrawer.java   View Source Code Vote up 6 votes
/**
 * 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);
}
 
Example 2
Project: rapidminer   File: ProcessDrawer.java   View Source Code Vote up 5 votes
/**
 * 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);
}
 
Example 3
Project: monarch   File: LifelineState.java   View Source Code Vote up 5 votes
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);
}
 
Example 4
Project: monarch   File: LifelineState.java   View Source Code Vote up 5 votes
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);
}
 
Example 5
Project: jdk8u-jdk   File: Test8004859.java   View Source Code Vote up 5 votes
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;
        }
    }
}
 
Example 6
Project: openjdk-jdk10   File: Test8004859.java   View Source Code Vote up 5 votes
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;
        }
    }
}
 
Example 7
Project: brModelo   File: InspectorItemSeparador.java   View Source Code Vote up 5 votes
@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);
}
 
Example 8
Project: geomapapp   File: ShipData.java   View Source Code Vote up 5 votes
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 );
}
 
Example 9
Project: geomapapp   File: MGGData.java   View Source Code Vote up 5 votes
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 );
}
 
Example 10
Project: incubator-netbeans   File: CoverageBar.java   View Source Code Vote up 4 votes
@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);
}
 
Example 11
Project: TrabalhoFinalEDA2   File: mxHtmlTextShape.java   View Source Code Vote up 4 votes
/**
 * 
 */
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);
	}
}
 
Example 12
Project: TrabalhoFinalEDA2   File: mxCurveLabelShape.java   View Source Code Vote up 4 votes
/**
 * 
 */
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;
	}
}
 
Example 13
Project: Tarski   File: mxHtmlTextShape.java   View Source Code Vote up 4 votes
/**
 * 
 */
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);
  }
}
 
Example 14
Project: Tarski   File: mxCurveLabelShape.java   View Source Code Vote up 4 votes
/**
 * 
 */
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;
  }
}
 
Example 15
Project: brModelo   File: InspectorItemCor.java   View Source Code Vote up 4 votes
@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);
        }
    }
 
Example 16
Project: brModelo   File: Legenda.java   View Source Code Vote up 4 votes
@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);
    }
 
Example 17
Project: geomapapp   File: PDB.java   View Source Code Vote up 4 votes
public void draw( Graphics2D g ) {
		float zoom = 1f / (float) map.getZoom();
		Rectangle2D.Float rect = new Rectangle2D.Float(-3f*zoom, -3f*zoom, 6f*zoom, 6f*zoom);
		Rectangle2D.Float rect1 = new Rectangle2D.Float(-2f*zoom, -2f*zoom, 4f*zoom, 4f*zoom);
		Rectangle2D bounds = g.getClipBounds();
		AffineTransform at = g.getTransform();
		g.setColor( Color.black);
		double lastX = 0;
		double lastY = 0;
		double x, y;
		int n = 0;
		g.setStroke( new BasicStroke(zoom) );
		model.setArea( map.getClipRect2D(), map.getZoom() );

		// First Column Corner Text
		table.setCornerText( model.current.length +" Stations");
		aTable.setCornerText( aModel.analyses.size() +" Analyses");
		sTable.setCornerText( sModel.samples.size() +" Samples");

		double x1 = bounds.getX();
		double x2 = x1+bounds.getWidth();
//		double wrap = map.getWrap();
		for( int i=0 ; i<model.toPlot.length ; i++) {
			x = PDBStation.stations[model.toPlot[i]].getX();
			if(wrap>0.)while(x<x1) x+=wrap;
			y = PDBStation.stations[model.toPlot[i]].getY();

			Color a = computeStationColor(model.toPlot[i]);
			if (a == null) continue;

			g.setColor(a);
			g.translate( x - lastX, y-lastY );
			g.draw(rect1);
			g.setColor(Color.black);
			g.draw(rect);
			if( wrap>0 && x+wrap < bounds.getX()+bounds.getWidth() ) {
				x += wrap;
				g.setColor(a);
				g.translate( wrap, 0.);
				g.draw(rect1);
				g.setColor( Color.black );
				g.draw(rect);
			}
			lastX = x;
			lastY = y;
		}
		current = -1;
		g.setTransform( at);
	}