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

The following are Jave code examples for showing how to use getWidth() 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: rapidminer   File: ScrollBarUI.java   View Source Code Vote up 6 votes
@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
	int x = (int) trackBounds.getX();
	int y = (int) trackBounds.getY();
	int w = (int) trackBounds.getWidth();
	int h = (int) trackBounds.getHeight();

	g.setColor(Colors.SCROLLBAR_TRACK_BACKGROUND);
	g.fillRect(x - 1, y - 1, w + 2, h + 2);

	g.setColor(Colors.SCROLLBAR_TRACK_BORDER);
	if (this.scrollbar.getOrientation() == Adjustable.HORIZONTAL) {
		g.drawLine(x, y, x + w, y);
	} else {
		g.drawLine(x, y, x, y + h);
	}
}
 
Example 2
Project: rapidminer   File: ScrollBarUI.java   View Source Code Vote up 6 votes
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
	int x = (int) thumbBounds.getX();
	int y = (int) thumbBounds.getY();
	int w = (int) thumbBounds.getWidth();
	int h = (int) thumbBounds.getHeight();

	if (c.isEnabled() && w > 0 && h > 0) {
		if (this.scrollbar.getOrientation() == Adjustable.HORIZONTAL) {
			h -= 1;
			y++;
			drawHorizThumb(g, x, y, w, h);
		} else {
			w -= 1;
			x++;
			drawVertThumb(g, x, y, w, h);
		}
	}
}
 
Example 3
Project: geomapapp   File: XMImage.java   View Source Code Vote up 6 votes
public void zoomIn(Point p) {
	if( image==null )return;
	Insets ins = border.getBorderInsets(this);
	Rectangle rect = getVisibleRect();
	double zoomX = getZoomX();
	double zoomY = getZoomY();
	double x = (double) (p.x - ins.left) / zoomX;
	double y = (double) (p.y - ins.top) / zoomY;
	double w = (double) rect.width - ins.left - ins.right;
	double h = (double) rect.height - ins.top - ins.bottom;
	if(xAvg==1) xRep*=2;
	else xAvg /=2;
	if(yAvg==1) yRep*=2;
	else yAvg /=2;
	zoomX = getZoomX();
	zoomY = getZoomY();
	invalidate();
	int newX = (int) (x*zoomX - rect.getWidth()*.5d);
	int newY = (int) (y*zoomY - rect.getHeight()*.5d);
	synchronized(this) {
		scroller.validate();
	}
	scroller.scrollTo(new Point(newX, newY));
	repaint();
}
 
Example 4
Project: rapidminer   File: AnnotationsDecorator.java   View Source Code Vote up 6 votes
/**
 * Makes sure the current editor height matches its content if the annotation was never resized.
 * If the annotation has been manually resized before, does nothing.
 *
 * @param anno
 *            the annotation currently in the editor
 */
private void updateEditorHeight(final WorkflowAnnotation anno) {
	if (anno.wasResized()) {
		return;
	}

	Rectangle bounds = editPane.getBounds();
	// height is either the pref height or the current height, depending on what is bigger
	int prefHeight;
	if (anno instanceof ProcessAnnotation) {
		prefHeight = (int) Math.max(getContentHeightOfEditor((int) bounds.getWidth()), bounds.getHeight());
	} else {
		prefHeight = Math.max(getContentHeightOfEditor((int) bounds.getWidth()), OperatorAnnotation.MIN_HEIGHT);
	}
	Rectangle newBounds = new Rectangle((int) bounds.getX(), (int) bounds.getY(), (int) bounds.getWidth(), prefHeight);
	if (!bounds.equals(newBounds)) {
		editPane.setBounds(newBounds);
		updateEditPanelPosition(newBounds, true);
		view.getModel().fireAnnotationMiscChanged(anno);
	}
}
 
Example 5
Project: sumo   File: WorldScreen.java   View Source Code Vote up 6 votes
public static Point2D getWorldtoScreen(double x, double y){
    
    Rectangle imageBounds=null;
    ReferencedEnvelope mapBounds=null;
    try{
//        mapBounds=map.getLayerBounds();
        imageBounds = mapFrame.getBounds();
        int width = (int)imageBounds.getWidth();
        int height = (int)imageBounds.getHeight();
    }catch(Exception e){
        
    } 
    
    
    AffineTransform world2screen =
    RendererUtilities.worldToScreenTransform(mapBounds, imageBounds);
    Point2D pointScreenAbsolute = new Point2D.Double(x, y);
    Point2D pointScreen = world2screen.transform(pointScreenAbsolute, null);
    return pointScreen;
}
 
Example 6
Project: text-position-detector   File: UniresolutionTextPositionDetector.java   View Source Code Vote up 6 votes
private static int[] getProjection(GrayImage edgeMap,
	Rectangle region, boolean horizontal) {

	int aMin = (int) (horizontal ? region.getY() : region.getX()),
		bMin = (int) (horizontal ? region.getX() : region.getY()),
		aLen = (int) (horizontal ? region.getHeight() : region.getWidth()),
		bLen = (int) (horizontal ? region.getWidth() : region.getHeight()),
		ind = 0;

	int[] res = new int[aLen];

	for (int a = aMin; a < aMin + aLen; ++a) {
		int total = 0;
		for (int b = bMin; b < bMin + bLen; ++b) {
			// TODO other possible strategy: counting edge pixels instead of
			//      taking their value into account
			total +=
				edgeMap.getValue(horizontal ? b : a, horizontal ? a : b);
		}
		res[ind] = total;
		++ind;
	}

	return res;
}
 
Example 7
Project: geomapapp   File: SCSImage2.java   View Source Code Vote up 6 votes
public void doZoom( Point p, double factor ) {
Rectangle rect = getVisibleRect();
double x = p.getX() / zoom;
		double y = p.getY() / zoom;
		double w = rect.getWidth();
		double h = rect.getHeight();
		zoom *= factor;
zoomX = zoomY = zoom;
		int newX = (int) (x*zoom - w*.5d);
		int newY = (int) (y*zoom - h*.5d);
		invalidate();
		scrollPane.validate();
		JScrollBar sb = scrollPane.getHorizontalScrollBar();
		sb.setValue(newX);
		sb = scrollPane.getVerticalScrollBar();
		sb.setValue(newY);
		repaint();
}
 
Example 8
Project: geomapapp   File: SCSImage.java   View Source Code Vote up 6 votes
public void doZoom( Point p, double factor ) {
Rectangle rect = getVisibleRect();
double x = p.getX() / zoom;
		double y = p.getY() / zoom;
		double w = rect.getWidth();
		double h = rect.getHeight();
		zoom *= factor;
		int newX = (int) (x*zoom - w*.5d);
		int newY = (int) (y*zoom - h*.5d);
		invalidate();
		scrollPane.validate();
		JScrollBar sb = scrollPane.getHorizontalScrollBar();
		sb.setValue(newX);
		sb = scrollPane.getVerticalScrollBar();
		sb.setValue(newY);
		repaint();
}
 
Example 9
Project: incubator-netbeans   File: FruchtermanReingoldLayout.java   View Source Code Vote up 5 votes
private void init() {
    int nds = scene.getNodes().size();
    bounds = new Rectangle(magicSizeConstant  + (magicSizeMultiplier * nds), 
                           magicSizeConstant  + (magicSizeMultiplier * nds)); //g.getMaximumBounds();
    temp = bounds.getWidth() / 10;
    forceConstant = 0.75 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds);
    
    GraphNode<I> rn = scene.getRootGraphNode();
    NodeWidget rw = getWidget(rn);
    rw.locX = bounds.getCenterX();
    rw.locY = bounds.getCenterY();
    rw.setFixed(true);
    layoutCirculary(scene.getNodes(), rn);
}
 
Example 10
Project: incubator-netbeans   File: ButtonCellRenderer.java   View Source Code Vote up 5 votes
@Override
public Component getTableCellRendererComponent (
    JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column
) {
    JLabel c = (JLabel)defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    
    if (value instanceof String) {
        Rectangle cellRect = table.getCellRect(row, column, false);
        String scCell = (String) value;
        Dimension d = new Dimension((int) cellRect.getWidth(), (int) cellRect.getHeight());
        if (panel == null)
            panel = new ShortcutCellPanel(scCell);
        panel.setText(scCell);
        panel.setSize(d);

        if (isSelected) {
            panel.setBgColor(table.getSelectionBackground());
            if (UIManager.getLookAndFeel ().getID ().equals ("GTK"))
                panel.setFgCOlor(table.getForeground(), true);
            else
                panel.setFgCOlor(table.getSelectionForeground(), true);
        } else {
            panel.setBgColor(c.getBackground());
            panel.setFgCOlor(c.getForeground(), false);
        }
        if (hasFocus) {
            panel.setBorder(c.getBorder());
        } else {
            panel.setBorder(null);
        }

        return panel;
    }
    else {
        return c;
    }
}
 
Example 11
Project: incubator-netbeans   File: DialogBoundsPreserver.java   View Source Code Vote up 5 votes
private boolean checkBounds(Rectangle r) {
    Rectangle[] screens = getScreenBounds();
    for (Rectangle screen : screens) {
        if (r.getX() >= screen.getX() && r.getY() >= screen.getY()
                && r.getX() + r.getWidth() < screen.getX() + screen.getWidth()
                && r.getY() + r.getHeight() < screen.getY() + screen.getHeight()) {
            return true;
        }
    }
    return false;
}
 
Example 12
Project: geomapapp   File: XMap.java   View Source Code Vote up 5 votes
/**
 * Gets the region currently displayed in Projection coordinates.
 * @return the region currently displayed in Projection coordinates.
 */
public Rectangle2D getClipRect2D() {
	Rectangle r = getVisibleRect();
	Dimension dim = getPreferredSize();
	r.width = Math.min(r.width, dim.width);
	r.height = Math.min(r.height, dim.height);
	AffineTransform at = new AffineTransform();
	if(rotation==1) {
		at.translate( 0., dim.getHeight() );
		at.rotate(-.5*Math.PI);
	} else if( rotation==2 ) {
		at.translate( dim.getWidth(), dim.getHeight() );
		at.rotate( Math.PI );
	} else if( rotation == 3) {
		at.translate( dim.getWidth(), 0. );
		at.rotate( .5*Math.PI );
	}
	if(rotation != 0) {
		Point2D p1 = at.transform(new Point(r.x,r.y), null);
		Point2D p2 = at.transform(new Point(r.x+r.width,r.y+r.width), null);
		r.x = (int) Math.min(p1.getX(), p2.getX());
		r.width = (int) Math.max(p1.getX(), p2.getX()) - r.x;
		r.y = (int) Math.min(p1.getY(), p2.getY());
		r.height = (int) Math.max(p1.getY(), p2.getY()) - r.y;
	}

	if(mapBorder != null) {
		Insets ins = mapBorder.getBorderInsets(this);
		r.width -= ins.left + ins.right;
		r.height -= ins.top + ins.bottom;
	}
	Rectangle2D.Double r2d = new Rectangle2D.Double(
			r.getX()/zoom, r.getY()/zoom,
			r.getWidth()/zoom, r.getHeight()/zoom);
	return r2d;
}
 
Example 13
Project: openjdk-jdk10   File: bug6219960.java   View Source Code Vote up 5 votes
private static boolean pressOK(Component comp) {

        JInternalFrame internalFrame
                = findModalInternalFrame(comp, QUESTION);

        if (internalFrame == null) {
            return false;
        }

        JButton button = (JButton) findButton(internalFrame);

        if (button == null) {
            return false;
        }

        try {
            Robot robot = new Robot();
            Point location = button.getLocationOnScreen();
            Rectangle bounds = button.getBounds();
            int centerX = (int) (location.getX() + bounds.getWidth() / 2);
            int centerY = (int) (location.getY() + bounds.getHeight() / 2);
            robot.mouseMove(centerX, centerY);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
        } catch (IllegalComponentStateException ignore) {
            return false;
        } catch (AWTException e) {
            throw new RuntimeException(e);
        }
        return true;
    }
 
Example 14
Project: rapidminer   File: OverviewPanel.java   View Source Code Vote up 5 votes
@Override
protected void paintComponent(Graphics graphics) {
	super.paintComponent(graphics);
	double scaleX = (double) getWidth() / (double) processRenderer.getWidth();
	double scaleY = (double) getHeight() / (double) processRenderer.getHeight();
	scale = Math.min(scaleX, scaleY);
	double scaledW = processRenderer.getWidth() * scale;
	double scaledH = processRenderer.getHeight() * scale;

	Graphics2D g = (Graphics2D) graphics.create();
	g.translate((getWidth() - scaledW) / 2d, (getHeight() - scaledH) / 2d);
	g.scale(scale, scale);

	g.setRenderingHints(ProcessDrawer.LOW_QUALITY_HINTS);
	processRenderer.getOverviewPanelDrawer().draw(g, true);

	g.setStroke(new BasicStroke((int) (1d / scale)));

	Rectangle visibleRect = processRenderer.getVisibleRect();
	Rectangle drawRect = new Rectangle((int) visibleRect.getX(), (int) visibleRect.getY(),
			(int) visibleRect.getWidth() - 1, (int) visibleRect.getHeight() - 1);

	g.setColor(FILL_COLOR);
	g.fill(drawRect);

	g.setColor(DRAW_COLOR);
	g.draw(drawRect);

	g.dispose();
}
 
Example 15
Project: openjdk-jdk10   File: JTreeOperator.java   View Source Code Vote up 5 votes
/**
 * Retuns points which can be used to click on path.
 *
 * @param row a row index to click on.
 * @return a Point in component's coordinate system.
 */
public Point getPointToClick(int row) {
    Rectangle rect = getRowBounds(row);
    if (rect != null) {
        return (new Point((int) (rect.getX() + rect.getWidth() / 2),
                (int) (rect.getY() + rect.getHeight() / 2)));
    } else {
        throw (new NoSuchPathException(row));
    }
}
 
Example 16
Project: convertigo-eclipse   File: JavelinConnectorComposite.java   View Source Code Vote up 4 votes
public void handleSelectionChanged(twinxEvent0 arg0) {
	final Javelin javelin = getJavelin();

	Rectangle selectedZone = javelin.getSelectionZone();
	final boolean bSelected = (selectedZone != null) && (selectedZone.getWidth() != 0)
			&& (selectedZone.getHeight() != 0);

	// enable or disable New beans buttons
	toolBarSetEnable("NewScreenClass", bSelected);
	toolBarSetEnable("NewTagName", bSelected);
	toolBarSetEnable("NewWaitAt", bSelected && connector.isLearning());

	// enable or disable the link button
	// getDisplay().syncExec(new Runnable() {
	// public void run() {
	// boolean enable = false;
	// if (projectExplorerView != null) {
	// BeanInfo bi =
	// projectExplorerView.getFirstSelectedDatabaseObjectBeanInfo();
	// if (bi != null) {
	// PropertyDescriptor pd =
	// ConvertigoPlugin.getDefault().getSelectedPropertyDescriptor(bi);
	// try {
	// enable = pd != null &&
	// bSelected &&
	// getLastDetectedScreenClass() != null &&
	// !javelin.getSelectionZone().isEmpty() &&
	// (
	// pd.getPropertyEditorClass().isAssignableFrom(
	// Class.forName("com.twinsoft.convertigo.eclipse.property_editors.ZoneEditor")
	// ) ||
	// pd.getPropertyEditorClass().isAssignableFrom(
	// Class.forName("com.twinsoft.convertigo.eclipse.property_editors.JavelinAttributeEditor")
	// ) ||
	// pd.getPropertyEditorClass().isAssignableFrom(
	// Class.forName("com.twinsoft.convertigo.eclipse.property_editors.JavelinStringEditor")
	// )
	// );
	// } catch (ClassNotFoundException e) {
	// enable = false;
	// }
	// }
	// }
	// toolBarSetEnable("Link", enable);
	// }
	// });

	// enable or disable the add button
	getDisplay().syncExec(new Runnable() {
		public void run() {
			boolean enable = false;
			if (projectExplorerView != null) {
				BeanInfo bi = ConvertigoPlugin.getDefault().getProjectExplorerView()
						.getFirstSelectedDatabaseObjectBeanInfo();
				if (bi != null) {
					PropertyDescriptor pd = ConvertigoPlugin.getDefault()
							.getSelectedPropertyDescriptor(bi);
					try {
						enable = pd != null
								&& bSelected
								&&
								// getLastDetectedScreenClass() != null &&
								// // seems to be broken and not very
								// usefull, commented for bug #952
								!javelin.getSelectionZone().isEmpty()
								&& (pd.getPropertyEditorClass().isAssignableFrom(Class
										.forName("com.twinsoft.convertigo.eclipse.property_editors.ColumnEditor")));
					} catch (ClassNotFoundException e) {
						enable = false;
					}
				}
			}
			toolBarSetEnable("Add", enable);
		}
	});
}
 
Example 17
Project: BrainControl   File: GraphPanel.java   View Source Code Vote up 4 votes
/**
	 * Painting of the Graph
	 */
	
	@Override
	public void paint(Graphics g) {

		
		//drawing the frame of the Graph
		Rectangle r = g.getClipBounds();
		g.setColor(Color.RED);
		g.drawRect(0, 0, (int)r.getWidth(), (int)r.getHeight());

		
		setBackground(Color.WHITE);
		
		g.setColor(Color.GRAY);
		
		
		final int minTime = Math.max(0, elapsedTime - coordinates.displayedTimeInterval);
//		final int maxTime = Math.max(elapsedTime, coordinates.displayedTimeInterval);
		final int graphWidth = (int)r.getWidth() - 2*offset;
		final int graphHeight = (int)r.getHeight() - 2*offset;
		
		//drawing the x axis
		g.drawLine(offset, (int)r.getHeight() - offset, (int)r.getWidth() - offset, (int)r.getHeight() - offset);
		//drawing the y axis
		g.drawLine(offset, offset, offset, (int)r.getHeight() - offset);
		
		g.setColor(Color.BLACK);
		
		//bold shows which reservoir is active and the name of it is to bold 
		if(reservoir.bold)
		{
			g.setFont(new Font("default", Font.BOLD, 14));
		}
		//draw name of reservoir
		g.drawString(reservoir.getName(), (int)(r.getWidth()/2-offset), offset);
		
		g.setFont(new Font("default", Font.PLAIN, 12));
		
		
		//String beginX = String.valueOf(minTime);
		//String endX = String.valueOf(coordinates.displayedTimeInterval + minTime);
		
		//label of the x axis
//		g.drawString(beginX, offset, (int)r.getHeight() - offset + 15);
//		g.drawString(endX, (int)r.getWidth() - offset,(int)r.getHeight() - offset + 15);
		
		//label of the y axis
		g.drawString("0", offset - 10, (int)r.getHeight() - offset);
		g.drawString("1", offset - 10, offset + 10);


		//drawing the graph: showing all the lines which connect the values that are saved in the list ReservoirCoordinate
		if(coordinates.size() > 1) {
			Iterator<ReservoirGuiCoordinate> it = coordinates.iterator();
			ReservoirGuiCoordinate lastCoordinate = it.next();
			Point lastGuiPoint = getGuiPoint(minTime, graphWidth, graphHeight, lastCoordinate);
			Point nextGuiPoint = null;
			while(it.hasNext()) {
				ReservoirGuiCoordinate nextCoordinate = it.next();
				nextGuiPoint = getGuiPoint(minTime, graphWidth, graphHeight, nextCoordinate);
				g.drawLine(lastGuiPoint.x, lastGuiPoint.y, nextGuiPoint.x, nextGuiPoint.y);
				lastGuiPoint = nextGuiPoint;
			}
		}
	
	}
 
Example 18
Project: JuggleMasterPro   File: ControlJFrame.java   View Source Code Vote up 4 votes
/**
 * Method description
 * 
 * @see
 */
final public void setLanguageJLabels(boolean bolPhideControlJFrame) {

	final Rectangle objLcontrolJFrameRectangle = this.getBounds();

	// Save the current configuration :
	final PatternsManager objLsavedJugglePatternsManager = this.getPatternsManager();
	final byte bytLsavedAnimationStatus = this.objGjuggleMasterPro.bytGanimationStatus;
	final int intLsavedObjectIndex = this.objGjuggleMasterPro.intGobjectIndex;

	// Set the special language pattern manager :
	final PatternsManager objLlanguageJugglePatternsManager = new PatternsManager(Constants.bytS_MANAGER_NEW_ABSTRACT_LANGUAGE);
	this.objGjuggleMasterPro.bytGanimationStatus = Constants.bytS_STATE_ANIMATION_PAUSED;
	this.objGjuggleMasterPro.intGobjectIndex = objLlanguageJugglePatternsManager.getPatternsFileManager().intGstartObjectIndex;
	this.setJugglePatternsManager(objLlanguageJugglePatternsManager);

	// Set dialog language :
	try {
		final Locale objLlocale = new Locale(this.getLanguageString(Language.intS_LANGUAGE_ISO_639_1_CODE));
		JComponent.setDefaultLocale(objLlocale);
	} catch (final Throwable objPthrowable) {
		Tools.err("Error while trying to apply ISO 639-1 language code");
	}

	// Place the widgets :
	this.setWidgetsPreferredSizes(false);
	this.setWidgetsControls();
	if (bolPhideControlJFrame) {
		this.setVisible(false);
		this.getJuggleMasterPro().getFrame().setVisible(false);
	}
	this.validate();
	this.pack();
	this.setWidgetsPreferredSizes(true);

	final int intLoldWidth = (int) objLcontrolJFrameRectangle.getWidth();
	final int intLnewWidth = Math.max(this.getWidth(), intLoldWidth);
	if (intLnewWidth > intLoldWidth) {
		this.setBounds(	Math.max(0, this.getX() - (intLnewWidth - intLoldWidth)),
						this.getY(),
						intLnewWidth,
						(int) objLcontrolJFrameRectangle.getHeight());
	} else {
		this.setBounds(	Math.max(0, (int) objLcontrolJFrameRectangle.getX()),
						this.getY(),
						intLoldWidth,
						(int) objLcontrolJFrameRectangle.getHeight());
	}
	if (bolPhideControlJFrame) {
		this.setVisible(true);
		this.getJuggleMasterPro().getFrame().setVisible(true);
		this.getJuggleMasterPro().getFrame().repaint();
	}

	// Restore the previous configuration :
	this.setJugglePatternsManager(objLsavedJugglePatternsManager);
	this.objGjuggleMasterPro.intGobjectIndex = intLsavedObjectIndex;
	this.objGjuggleMasterPro.bytGanimationStatus = bytLsavedAnimationStatus;
	this.setWidgetsControls();
	this.setJButtonsEnabled(true);
	this.repaint();

	// Set the menus :
	this.setMenusJLabels();
	this.setMenusEnabled();
	this.objGjuggleMasterPro.objGdataJFrame.setHeaders();
	this.objGjuggleMasterPro.objGdataJFrame.setButtonsJLabels();
}
 
Example 19
Project: Java-Swing-Helper   File: SwingWindow.java   View Source Code Vote up 4 votes
/**
 * Run the render method of the given component.
 * 
 * @param comp
 */
private void doRender(Component comp) {
	if (rendered.contains(System.identityHashCode(comp))) {
		return;
	}
	rendered.add(System.identityHashCode(comp));
	if (comp instanceof Container) {
		Container cont = (Container) comp;
		for (Component comp2 : cont.getComponents()) {
			doRender(comp2);
		}
	}

	float[] scale = getScalef();

	Component originalComponent = null;
	try {
		originalComponent = deserializeObject(JComponent.class, originalComps.get(System.identityHashCode(comp)));
	} catch (ClassNotFoundException | IOException e) {
		e.printStackTrace();
	}

	if (originalComponent != null) {
		// Bounds
		if (isWindowOptionEnabled(WindowOptions.SCALE_COMPONENTS)) {
			Rectangle original = originalComponent.getBounds();
			int newX = (int) (original.getX() * scale[0]);
			int newY = (int) (original.getY() * scale[1]);
			int newW = (int) (original.getWidth() * scale[0]);
			int newH = (int) (original.getHeight() * scale[1]);
			comp.setBounds(newX, newY, newW, newH);
		}

		// Fonts
		if (isWindowOptionEnabled(WindowOptions.SCALE_FONTS)) {
			if (comp.getFont() != null && originalComponent.getFont() != null) {
				Font font = comp.getFont();
				Font newFont = font.deriveFont(font.getStyle(),
						getSuggestedFontSize(originalComponent.getFont().getSize()));
				comp.setFont(newFont);
			}
		}

		// Images
		if (isWindowOptionEnabled(WindowOptions.SCALE_IMAGES)) {
			if (comp instanceof JLabel) {
				JLabel label = (JLabel) comp;
				JLabel orig = (JLabel) originalComponent;
				label.setIcon(getScaledImageIcon(orig));
			}
		}
	}
}
 
Example 20
Project: geomapapp   File: XYGraph.java   View Source Code Vote up 4 votes
public void paintComponent( Graphics graphics ) {
	line = null;
	Dimension dim = getPreferredSize();
	Graphics2D g = (Graphics2D) graphics;
	if(!printing) g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
					RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
	Rectangle r = getVisibleRect();
	if( !imaging ) {
		g.setColor(Color.white);
		g.fill( r );
	}
	Rectangle2D.Double bounds = new Rectangle2D.Double();
	Insets ins = axes.getInsets();
	double w = (double)(r.width - ins.left - ins.right);
	double h = (double)(r.height - ins.top - ins.bottom);
	double sX, sY;
	if( tracksWidth  || scPane==null) {
		bounds.x = xRange[0];
		bounds.width = xRange[1]-xRange[0];
		sX = w / bounds.width;
	} else {
		bounds.x = xRange[0] + (double)(r.x) / (xScale*zoom);
		bounds.width = w / (xScale*zoom);
		sX = xScale*zoom;
	}
	if( tracksHeight || scPane==null ) {
		bounds.y = yRange[1];
		bounds.height = yRange[0]-yRange[1];
		sY = h / bounds.height;
	} else {
		bounds.y = yRange[1] + (double)(r.y) / (yScale*zoom);
		bounds.height = (double)(r.height - ins.top - ins.bottom) / (yScale*zoom);
		sY = yScale*zoom;
	}
	if(printing) {
		double scale = (r.getWidth()-ins.left-ins.right)
			/(printRect.getWidth()-ins.top-ins.bottom);
		sX /= scale;
		sY /= scale;
		r = printRect;
	}
	axes.drawAxes( g, bounds, r );
	g.clipRect( r.x+ins.left, r.y+ins.top, 
		r.width-ins.left-ins.right, 
		r.height-ins.top-ins.bottom );
	g.translate( r.x+ins.left, r.y+ins.top );
	xy.plotXY( g, bounds, sX, sY, dataIndex );
}