Java Code Examples for java.awt.Rectangle.grow()

The following are Jave code examples for showing how to use grow() of the java.awt.Rectangle 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: brModelo   File: baseDrawerItem.java   View Source Code Vote up 6 votes
public void DrawImagem(Graphics2D g) {
    BufferedImage img = getImagem();
    if (img == null) {
        return;
    }
    int[] pts = ArrayDePontos(getPosiImagem());
    if (pts.length != 4) {
        posiImagem = "L,T,200,200";
        imgres = null;
        pts = ArrayDePontos(getPosiImagem());
    }
    Rectangle rec = new Rectangle(pts[0], pts[1], pts[2], pts[3]);
    rec.grow(-2, -2);
    if (imgres == null) {
        imgres = img.getScaledInstance(rec.width, rec.height, Image.SCALE_SMOOTH);
    }
    g.drawImage(imgres, rec.x, rec.y, null);
}
 
Example 2
Project: incubator-netbeans   File: ProjectColorTabDecorator.java   View Source Code Vote up 6 votes
@Override
public void paintAfter( TabData tab, Graphics g, Rectangle tabRect, boolean isSelected ) {
    if( !isSelected || !Settings.getDefault().isSameProjectSameColor() )
        return;
    Color c = null;
    synchronized( tab2color ) {
        c = tab2color.get( tab );
        if( null == c ) {
            c = getColorForTab( tab );
            if( null == c )
                return;
            tab2color.put( tab, c );
        }
    }
    g.setColor( c );
    Rectangle rect = new Rectangle( tabRect );
    rect.y += rect.height - 3;
    rect.grow( -1, -1 );
    g.fillRect( rect.x, rect.y, rect.width, rect.height );
}
 
Example 3
Project: brModelo   File: PontoDeLinha.java   View Source Code Vote up 6 votes
/**
 * Liga uma linha a um objeto manualmente (sem o uso do mouse).
 *
 * @param res
 * @return
 */
public boolean LigarA(Elementar res) {
    boolean sn = false;
    if (res instanceof Forma) {
        setEm((Forma) res);
        if (getEm() != null) {
            getEm().PosicionePonto(this);
            getDono().OrganizeLinha();
            sn = true;
        }
    }
    getDono().reSetBounds();
    ReenquadreLinha();
    Rectangle rec = getBounds();
    rec.grow(5, 5);
    InvalidateArea(rec);
    //ProcessaOverDraw(true);
    return sn;
}
 
Example 4
Project: ramus   File: ScrollPanePreview.java   View Source Code Vote up 6 votes
private void moveRectangle(int aDeltaX, int aDeltaY) {
    if (theStartRectangle == null)
        return;

    Insets insets = getInsets();
    Rectangle newRect = new Rectangle(theStartRectangle);
    newRect.x += aDeltaX;
    newRect.y += aDeltaY;
    newRect.x = Math.min(Math.max(newRect.x, insets.left), getWidth()
            - insets.right - newRect.width);
    newRect.y = Math.min(Math.max(newRect.y, insets.right), getHeight()
            - insets.bottom - newRect.height);
    Rectangle clip = new Rectangle();
    Rectangle.union(theRectangle, newRect, clip);
    clip.grow(2, 2);
    theRectangle = newRect;
    paintImmediately(clip);
}
 
Example 5
Project: brModelo   File: Desenhador.java   View Source Code Vote up 6 votes
public void DrawImagem(Graphics2D g) {
    BufferedImage imgB = getImagem();
    if (imgB == null) {
        return;
    }
    Rectangle rec = getBounds();
    rec.grow(-2, -2);
    if (imgres == null) {
        imgres = imgB.getScaledInstance(rec.width, rec.height, Image.SCALE_SMOOTH);
    }

    Composite originalComposite = g.getComposite();
    if (alfa != 1f) {
        int type = AlphaComposite.SRC_OVER;
        g.setComposite(AlphaComposite.getInstance(type, alfa));
    }
    Image img = imgres;
    if (isDisablePainted()) {
        img = util.Utilidades.dye(new ImageIcon(imgres), disabledColor);
    }
    
    g.drawImage(img, rec.x, rec.y, null);
    g.setComposite(originalComposite);
}
 
Example 6
Project: TrabalhoFinalEDA2   File: mxGraphOutline.java   View Source Code Vote up 6 votes
/**
 * 
 */
public void updateFinderBounds(Rectangle bounds, boolean repaint)
{
	if (bounds != null && !bounds.equals(finderBounds))
	{
		Rectangle old = new Rectangle(finderBounds);
		finderBounds = bounds;

		// LATER: Fix repaint region to be smaller
		if (repaint)
		{
			old = old.union(finderBounds);
			old.grow(3, 3);
			repaint(old);
		}
	}
}
 
Example 7
Project: Tarski   File: mxCellMarker.java   View Source Code Vote up 6 votes
/**
 * Marks the markedState and fires a mxEvent.MARK event.
 */
public void mark() {
  if (markedState != null) {
    Rectangle bounds = markedState.getRectangle();
    bounds.grow(3, 3);
    bounds.width += 1;
    bounds.height += 1;
    setBounds(bounds);

    if (getParent() == null) {
      setVisible(true);

      if (KEEP_ON_TOP) {
        graphComponent.getGraphControl().add(this, 0);
      } else {
        graphComponent.getGraphControl().add(this);
      }
    }

    repaint();
    eventSource.fireEvent(new mxEventObject(mxEvent.MARK, "state", markedState));
  }
}
 
Example 8
Project: MaxSim   File: LoopClusterWidget.java   View Source Code Vote up 6 votes
public void updateClusterBounds(){      
    Rectangle boundRect=null;
    
    for(NodeWidget nw : this.members){
        if(boundRect==null){
            boundRect = nw.convertLocalToScene(nw.getBounds());  
        } else {
            boundRect = boundRect.union(nw.convertLocalToScene(nw.getBounds()));
        }  
    }
    if(boundRect==null) return;
    for(Widget w : this.getChildren()) {
        if(w instanceof LoopClusterWidget) {            
            LoopClusterWidget lc = (LoopClusterWidget)w;
            lc.updateClusterBounds();
            boundRect = boundRect.union(w.convertLocalToScene(w.getBounds()));
        }
    }
   
    boundRect.grow(INSET, INSET);
    this.setPreferredBounds(boundRect);               
}
 
Example 9
Project: incubator-netbeans   File: DependencyGraphScene.java   View Source Code Vote up 5 votes
@Override
protected void performLayout() {
    Rectangle rectangle = null;
    List<? extends Widget> toFit = widgets != null ? widgets : depScene.getChildren();
    if (toFit == null) {
        return;
    }

    for (Widget widget : toFit) {
        Rectangle bounds = widget.getBounds();
        if (bounds == null) {
            continue;
        }
        if (rectangle == null) {
            rectangle = widget.convertLocalToScene(bounds);
        } else {
            rectangle = rectangle.union(widget.convertLocalToScene(bounds));
        }
    }
    // margin around
    if (widgets == null) {
        rectangle.grow(5, 5);
    } else {
        rectangle.grow(25, 25);
    }
    Dimension dim = rectangle.getSize();
    Dimension viewDim = parentScrollPane.getViewportBorderBounds().getSize ();
    double zf = Math.min ((double) viewDim.width / dim.width, (double) viewDim.height / dim.height);
    if (depScene.isAnimated()) {
        if (widgets == null) {
            depScene.getSceneAnimator().animateZoomFactor(zf);
        } else {
            CenteredZoomAnimator cza = new CenteredZoomAnimator(depScene.getSceneAnimator());
            cza.setZoomFactor(zf,
                    new Point((int)rectangle.getCenterX(), (int)rectangle.getCenterY()));
        }
    } else {
        depScene.setMyZoomFactor (zf);
    }
}
 
Example 10
Project: brModelo   File: Elementar.java   View Source Code Vote up 5 votes
/**
 * Nome da função de repintura em C#. Em Java sera repaint.
 * Repinta apenas a área do componente
 */
public void InvalidateArea() {
    if (master != null) {
        Rectangle r = (Rectangle)clientRectangle.clone();
        r.grow(1, 1);
        master.repaint(r);
    }
}
 
Example 11
Project: brModelo   File: Forma.java   View Source Code Vote up 5 votes
public Rectangle getSuperArea() {
    int espacoL = distSelecao;
    int mW = getMaster().getPontoWidth() + espacoL;
    int mH = getMaster().getPontoHeigth() + espacoL;
    Rectangle rec = getClientRectangle().getBounds();
    rec.grow(mW, mH);
    return rec;
}
 
Example 12
Project: incubator-netbeans   File: XChartSelectionOverlay.java   View Source Code Vote up 5 votes
private void paintRect(int x, int y, int w, int h, int t) {
    if (w != 0 && h != 0) {
        Rectangle rect = new Rectangle(x, y, w, h);
        rect.grow(t, t);
        paintImmediately(rect);
    }
}
 
Example 13
Project: brModelo   File: PontoDeLinha.java   View Source Code Vote up 5 votes
@Override
    public void mouseReleased(MouseEvent e) {
        isMouseDown = false;
        dragging = false;

        if (IsTopOrBotton) {
            Elementar res = getMaster().CaptureBaseFromPoint(null, e.getPoint());
            if (res instanceof Forma) {
                res = res.ProcessaComposicao(e.getPoint());
//                if (res.isComposto()) {
//                    res = res.ProcessaComposicao(e.getPoint());
//                }
                setEm((Forma) res);
                if (getEm() != null) {
                    getEm().PosicionePonto(this);
                    getDono().OrganizeLinha();
                }
            } else {
                setEm(null);
            }
        }
        getDono().reSetBounds();
        ReenquadreLinha();
        Rectangle rec = getBounds();
        rec.grow(5, 5);
        InvalidateArea(rec);
        ProcessaOverDraw(true);
        super.mouseReleased(e);
    }
 
Example 14
Project: rapidminer   File: ExtendedJTableSorterModel.java   View Source Code Vote up 5 votes
private int getSortingColumnIndex(JTableHeader header, Point p, int column) {
	if (column == -1) {
		return -1;
	}

	Rectangle r = header.getHeaderRect(column);
	r.grow(-4, 0);

	if (!r.contains(p)) {
		return -1;
	} else {
		return column;
	}
}
 
Example 15
Project: TrabalhoFinalEDA2   File: mxCellMarker.java   View Source Code Vote up 5 votes
/**
 * Marks the markedState and fires a mxEvent.MARK event.
 */
public void mark()
{
	if (markedState != null)
	{
		Rectangle bounds = markedState.getRectangle();
		bounds.grow(3, 3);
		bounds.width += 1;
		bounds.height += 1;
		setBounds(bounds);

		if (getParent() == null)
		{
			setVisible(true);

			if (KEEP_ON_TOP)
			{
				graphComponent.getGraphControl().add(this, 0);
			}
			else
			{
				graphComponent.getGraphControl().add(this);
			}
		}

		repaint();
		eventSource.fireEvent(new mxEventObject(mxEvent.MARK, "state",
				markedState));
	}
}
 
Example 16
Project: Tarski   File: mxGraphOutline.java   View Source Code Vote up 5 votes
/**
 * 
 */
public void updateFinderBounds(Rectangle bounds, boolean repaint) {
  if (bounds != null && !bounds.equals(finderBounds)) {
    Rectangle old = new Rectangle(finderBounds);
    finderBounds = bounds;

    // LATER: Fix repaint region to be smaller
    if (repaint) {
      old = old.union(finderBounds);
      old.grow(3, 3);
      repaint(old);
    }
  }
}
 
Example 17
Project: brModelo   File: PontoDeLinha.java   View Source Code Vote up 5 votes
@Override
public void mouseEntered(MouseEvent e) {
    super.mouseEntered(e); //To change body of generated methods, choose Tools | Templates.
    entrou = true;
    Rectangle r = getBounds();
    int x = r.width / 2;
    int y = r.height / 2;
    //r = new Rectangle(r.x - x, r.y - y, r.width * 2, r.height * 2);
    r.grow(x + 2, y + 2);
    InvalidateArea(r);
}
 
Example 18
Project: jdk8u-jdk   File: SourceClippingBlitTest.java   View Source Code Vote up 4 votes
public void runTests() {
        GraphicsConfiguration gc = getGraphicsConfiguration();
        for (Image srcIm :
            new Image[] {
                getBufferedImage(gc, IMAGEW, IMAGEH,
                        BufferedImage.TYPE_INT_RGB, true),
                getBufferedImage(gc, IMAGEW, IMAGEH,
                        BufferedImage.TYPE_INT_RGB, false),
                // commented out due to 6593406
//                getBMImage(gc, IMAGEW, IMAGEH),
//                getBufferedImage(gc, IMAGEW, IMAGEH,
//                        BufferedImage.TYPE_INT_ARGB, true),
//                getBufferedImage(gc, IMAGEW, IMAGEH,
//                        BufferedImage.TYPE_INT_ARGB, false),
                getVImage(gc, IMAGEW, IMAGEH),
            })
        {
            System.out.println("Testing source: " + srcIm);
            // wiggle the source and dest rectangles
            try {
                for (int locationVar = -10; locationVar < 20; locationVar += 10)
                {
                    for (int sizeVar = -10; sizeVar < 20; sizeVar += 10) {
                        Rectangle srcRect = (Rectangle)IMAGE_BOUNDS.clone();
                        srcRect.translate(locationVar, locationVar);
                        srcRect.grow(sizeVar, sizeVar);

                        Rectangle dstRect =
                                new Rectangle(sizeVar, sizeVar,
                                srcRect.width, srcRect.height);
                        System.out.println("testing blit rect src: " + srcRect);
                        System.out.println("                  dst: " + dstRect);
                        render(getGraphics(), srcIm, srcRect, dstRect);
                        test(srcRect, dstRect);
                    }
                }
                System.out.println("Test passed.");
            } finally {
                synchronized (lock) {
                    done = true;
                    lock.notifyAll();
                }
            }
        }
    }
 
Example 19
Project: omr-dataset-tools   File: NonesBuilder.java   View Source Code Vote up 4 votes
/**
 * Insert some None symbols in the page.
 *
 * @param toAdd desired number of None symbols to add
 * @return the list of inserted (None) symbols
 */
public List<SymbolInfo> insertNones (int toAdd)
{
    if (!checkInterlineValue()) {
        logger.info("Page has several interline values, no None symbol can be inserted.");

        return Collections.emptyList();
    }

    // Adjust margin to sheet interline value
    final double ratio = (double) INTERLINE / roundedInterline;
    final int xMargin = (int) Math.rint(NONE_X_MARGIN / ratio);
    final int yMargin = (int) Math.rint(NONE_Y_MARGIN / ratio);

    int maxWidth = fillWithSymbols();
    maxWidth = Math.max(maxWidth, 2 * xMargin); // Safer

    // Created None symbols
    final List<SymbolInfo> createdSymbols = new ArrayList<SymbolInfo>();
    final int sheetWidth = annotations.getSheetInfo().dim.width;
    final int sheetHeight = annotations.getSheetInfo().dim.height;

    // Ordinates occupied by standard symbols
    final boolean[] occupiedYs = getOccupiedYs(sheetHeight);

    // Put a reasonable limit on creation attempts
    for (int i = 10 * toAdd; i >= 0; i--) {
        if (createdSymbols.size() >= toAdd) {
            break; // Normal exit
        }

        // Make sure we pick a y within some valid symbol vertical range
        final int y = (int) Math.rint(Math.random() * sheetHeight);

        if ((y >= 0) && (y < sheetHeight) && occupiedYs[y]) {
            final int x = (int) Math.rint(Math.random() * sheetWidth);
            final Rectangle rect = new Rectangle(x, y, 0, 0);
            rect.grow(xMargin, yMargin);

            if (tryInsertion(rect, maxWidth)) {
                createdSymbols.add(
                        new SymbolInfo(
                                OmrShape.none,
                                roundedInterline,
                                null,
                                null,
                                new Rectangle(x, y, 0, 0)));
            }
        }
    }

    return createdSymbols;
}
 
Example 20
Project: MaxSim   File: PolylineRouter.java   View Source Code Vote up 4 votes
private boolean intersects(Widget w, List<Point> list) {
    Rectangle r = w.convertLocalToScene(w.getBounds());
    r.grow(HEXPAND, VEXPAND);
    return intersects(list, r);
}