@Override public void refreshContainer() { if (!this.isMaximum()) { int height = this.getHeight(); int pos = this.scrollPane.getVerticalScrollBar().getValue(); this.validate(); this.pack(); // this.setMaximumSize(this.getPreferredSize()); Rectangle bounds = this.getBounds(); bounds.height = height; bounds.width += 32; int x2 = (int) Math.min( bounds.getMaxX(), this.getEditorInterface().getDesktopPane().getBounds().getMaxX()); int y2 = (int) Math.min( bounds.getMaxY(), this.getEditorInterface().getDesktopPane().getBounds().getMaxY()); bounds.setFrameFromDiagonal(bounds.x, bounds.y, x2, y2); this.setBounds(bounds); this.scrollPane.getVerticalScrollBar().setValue(pos); } }
/** @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) */ public void paintComponent(Graphics g) { // long t1 = System.currentTimeMillis(); VolatileImage image = createVolatileImage(); Graphics gh = image.createGraphics(); gh.setColor(getLayoutControl().getBackground()); gh.fillRect(0, 0, image.getWidth(), image.getHeight()); getLayoutControl().getLayoutDraw().drawRectangle((Graphics2D) gh); gh.drawImage(getLayoutControl().getImage(), 0, 0, null); gh.drawImage(getLayoutControl().getImgRuler(), 0, 0, null); // long t2 = System.currentTimeMillis(); // BufferedImage img = getLayoutControl().getImage(); // BufferedImage imgRuler=getLayoutControl().getImgRuler(); // g.drawImage(img, 0, 0, getLayoutControl()); // g.drawImage(imgRuler, 0, 0, getLayoutControl()); gh.setColor(Color.black); gh.setXORMode(Color.white); // Borramos el anterior Rectangle r = new Rectangle(); // Dibujamos el actual if (dragged && (getLayoutControl().getFirstPoint() != null) && (getLayoutControl().getLastPoint() != null)) { r.setFrameFromDiagonal(getLayoutControl().getFirstPoint(), getLayoutControl().getLastPoint()); gh.drawRect(r.x, r.y, r.width, r.height); } IFFrame[] frames = getLayoutControl().getLayoutContext().getFFrameSelected(); for (int i = 0; i < frames.length; i++) { gh.setColor(Color.black); frames[i].drawHandlers((Graphics2D) gh); } gh.setPaintMode(); // getLayoutControl().drawCursor(gh); g.drawImage(image, 0, 0, null); // long t3 = System.currentTimeMillis(); // System.out.println("t1 = " + (t2-t1) + " t2=" + (t3-t2)); }
/** @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) */ public void paintComponent(Graphics g) { // VolatileImage image = createVolatileImage(); // Graphics gh = image.createGraphics(); // gh.setColor(getLayoutControl().getBackground()); // gh.fillRect(0, 0, image.getWidth(), image.getHeight()); // // getLayoutControl().getLayoutDraw().drawRectangle((Graphics2D) gh); // gh.drawImage(getLayoutControl().getImgRuler(),0,0,null); // gh.drawImage(getLayoutControl().getImage(),0,0,null); // getLayoutControl().getLayoutDraw().drawGrid((Graphics2D) gh); // // getLayoutControl().getLayoutDraw().drawHandlers((Graphics2D)gh, Color.black); // gh.setColor(Color.black); // gh.setXORMode(Color.white); if (getLayoutControl().getImage() != null) { g.setColor(getLayoutControl().getBackground()); g.fillRect( 0, 0, getLayoutControl().getImage().getWidth(), getLayoutControl().getImage().getHeight()); getLayoutControl().getLayoutDraw().drawRectangle((Graphics2D) g); g.setColor(Color.black); g.drawImage(getLayoutControl().getImage(), 0, 0, null); g.drawImage(getLayoutControl().getImgRuler(), 0, 0, null); } g.setColor(Color.black); g.setXORMode(Color.white); if (getLayoutControl().isReSel()) { Rectangle reSel = getLayoutControl().getReSel(); reSel = new Rectangle(); reSel.setFrameFromDiagonal( getLayoutControl().getFirstPoint(), getLayoutControl().getLastPoint()); // gh.drawRect(reSel.x, reSel.y, reSel.width, reSel.height); g.drawRect(reSel.x, reSel.y, reSel.width, reSel.height); } IFFrame[] frames = getLayoutControl().getLayoutContext().getFFrameSelected(); for (int i = 0; i < frames.length; i++) { // gh.setColor(Color.black); frames[i].drawHandlers((Graphics2D) g); int difx = (getLayoutControl().getLastPoint().x - getLayoutControl().getFirstPoint().x); int dify = (getLayoutControl().getLastPoint().y - getLayoutControl().getFirstPoint().y); if ((Math.abs(difx) > 3) || (Math.abs(dify) > 3)) { Rectangle2D rectangle = frames[i].getMovieRect(difx, dify); if (rectangle == null) return; ((Graphics2D) g) .rotate( Math.toRadians(frames[i].getRotation()), rectangle.getX() + (rectangle.getWidth() / 2), rectangle.getY() + (rectangle.getHeight() / 2)); if (rectangle != null && dragged && !getLayoutControl().isReSel()) { g.drawRect( (int) rectangle.getMinX(), (int) rectangle.getMinY(), (int) rectangle.getWidth(), (int) rectangle.getHeight()); } ((Graphics2D) g) .rotate( Math.toRadians(-frames[i].getRotation()), rectangle.getX() + (rectangle.getWidth() / 2), rectangle.getY() + (rectangle.getHeight() / 2)); } } // long t2 = System.currentTimeMillis(); g.setPaintMode(); // getLayoutControl().getLayoutDraw().drawRuler((Graphics2D) gh, Color.black); // g.drawImage(image,0,0,null); // getLayoutControl().getLayoutDraw().drawRectangle((Graphics2D) g); // g.drawImage(getLayoutControl().getImage(), 0, 0, getLayoutControl()); // getLayout().getLayoutDraw().drawHandlers((Graphics2D) g, Color.black); // if (getLayoutControl().isReSel()) { // Rectangle reSel=getLayoutControl().getReSel(); // reSel=new Rectangle(); // reSel.setFrameFromDiagonal(getLayoutControl().getFirstPoint(), // getLayoutControl().getLastPoint()); // g.drawRect(reSel.x, reSel.y, reSel.width, reSel.height); // } // IFFrame[] frames = getLayoutControl().getLayoutContext().getFFrameSelected(); // for (int i = 0; i < frames.length; i++) { // g.setColor(Color.black); // frames[i].drawHandlers((Graphics2D) g); // int difx = (getLayoutControl().getLastPoint().x - // getLayoutControl().getFirstPoint().x); // int dify = (getLayoutControl().getLastPoint().y - // getLayoutControl().getFirstPoint().y); // if ((Math.abs(difx) > 3) || (Math.abs(dify) > 3)) { // Rectangle2D rectangle = frames[i].getMovieRect(difx, dify); // if (rectangle == null) // return; // ((Graphics2D) g).rotate(Math.toRadians(frames[i] // .getRotation()), rectangle.getX() // + (rectangle.getWidth() / 2), rectangle.getY() // + (rectangle.getHeight() / 2)); // // if (rectangle != null && dragged && !getLayoutControl().isReSel()) { // g.drawRect((int) rectangle.getMinX(), (int) rectangle // .getMinY(), (int) rectangle.getWidth(), // (int) rectangle.getHeight()); // } // // ((Graphics2D) g).rotate(Math.toRadians(-frames[i] // .getRotation()), rectangle.getX() // + (rectangle.getWidth() / 2), rectangle.getY() // + (rectangle.getHeight() / 2)); // // } // } // // //g.setClip(rClip); // g.drawImage(getLayoutControl().getImgRuler(), 0, 0, getLayoutControl()); }