src/main/java/com/mxgraph/swing/mxGraphOutline.java
public boolean updateScaleAndTranslate()
	{
		double newScale = 1;
		int dx = 0;
		int dy = 0;

		if (this.graphComponent != null)
		{
			Dimension graphSize = graphComponent.getGraphControl().getSize();
			Dimension outlineSize = getSize();

			int gw = (int) graphSize.getWidth();
			int gh = (int) graphSize.getHeight();

			if (gw > 0 && gh > 0)
			{
				boolean magnifyPage = graphComponent.isPageVisible()
						&& isFitPage()
						&& graphComponent.getHorizontalScrollBar().isVisible()
						&& graphComponent.getVerticalScrollBar().isVisible();
				double graphScale = graphComponent.getGraph().getView()
						.getScale();
				mxPoint trans = graphComponent.getGraph().getView()
						.getTranslate();

				int w = (int) outlineSize.getWidth() - 2 * outlineBorder;
				int h = (int) outlineSize.getHeight() - 2 * outlineBorder;

				if (magnifyPage)
				{
					gw -= 2 * Math.round(trans.getX() * graphScale);
					gh -= 2 * Math.round(trans.getY() * graphScale);
				}

				newScale = Math.min((double) w / gw, (double) h / gh);

				dx += (int) Math
						.round((outlineSize.getWidth() - gw * newScale) / 2);
				dy += (int) Math
						.round((outlineSize.getHeight() - gh * newScale) / 2);

				if (magnifyPage)
				{
					dx -= Math.round(trans.getX() * newScale * graphScale);
					dy -= Math.round(trans.getY() * newScale * graphScale);
				}
			}
		}

		if (newScale != scale || translate.x != dx || translate.y != dy)
		{
			scale = newScale;
			translate.setLocation(dx, dy);

			return true;
		}
		else
		{
			return false;
		}
	}
/**
	 * Returns true if the scale or translate has changed.
	 */
Returns true if the scale or translate has changed.
Returns true if the scale or translate has changed .
public boolean updateScaleAndTranslate()
	{
		double newScale = 1;
		int dx = 0;
		int dy = 0;
		if (this.graphComponent != null)
		{
			Dimension graphSize = graphComponent.getGraphControl().getSize();
			Dimension outlineSize = getSize();
			int gw = (int) graphSize.getWidth();
			int gh = (int) graphSize.getHeight();
			if (gw > 0 && gh > 0)
			{
				boolean magnifyPage = graphComponent.isPageVisible()
						&& isFitPage()
						&& graphComponent.getHorizontalScrollBar().isVisible()
						&& graphComponent.getVerticalScrollBar().isVisible();
				double graphScale = graphComponent.getGraph().getView()
						.getScale();
				mxPoint trans = graphComponent.getGraph().getView()
						.getTranslate();
				int w = (int) outlineSize.getWidth() - 2 * outlineBorder;
				int h = (int) outlineSize.getHeight() - 2 * outlineBorder;
				if (magnifyPage)
				{
					gw -= 2 * Math.round(trans.getX() * graphScale);
					gh -= 2 * Math.round(trans.getY() * graphScale);
				}
				newScale = Math.min((double) w / gw, (double) h / gh);
				dx += (int) Math
						.round((outlineSize.getWidth() - gw * newScale) / 2);
				dy += (int) Math
						.round((outlineSize.getHeight() - gh * newScale) / 2);
				if (magnifyPage)
				{
					dx -= Math.round(trans.getX() * newScale * graphScale);
					dy -= Math.round(trans.getY() * newScale * graphScale);
				}
			}
		}
		if (newScale != scale || translate.x != dx || translate.y != dy)
		{
			scale = newScale;
			translate.setLocation(dx, dy);
			return true;
		}
		else
		{
			return false;
		}
	}
public boolean updateScaleAndTranslate ( ) { double newScale = 1 ; int dx = 0 ; int dy = 0 ; if ( this . graphComponent != null ) { Dimension graphSize = graphComponent . getGraphControl ( ) . getSize ( ) ; Dimension outlineSize = getSize ( ) ; int gw = ( int ) graphSize . getWidth ( ) ; int gh = ( int ) graphSize . getHeight ( ) ; if ( gw > 0 && gh > 0 ) { boolean magnifyPage = graphComponent . isPageVisible ( ) && isFitPage ( ) && graphComponent . getHorizontalScrollBar ( ) . isVisible ( ) && graphComponent . getVerticalScrollBar ( ) . isVisible ( ) ; double graphScale = graphComponent . getGraph ( ) . getView ( ) . getScale ( ) ; mxPoint trans = graphComponent . getGraph ( ) . getView ( ) . getTranslate ( ) ; int w = ( int ) outlineSize . getWidth ( ) - 2 * outlineBorder ; int h = ( int ) outlineSize . getHeight ( ) - 2 * outlineBorder ; if ( magnifyPage ) { gw -= 2 * Math . round ( trans . getX ( ) * graphScale ) ; gh -= 2 * Math . round ( trans . getY ( ) * graphScale ) ; } newScale = Math . min ( ( double ) w / gw , ( double ) h / gh ) ; dx += ( int ) Math . round ( ( outlineSize . getWidth ( ) - gw * newScale ) / 2 ) ; dy += ( int ) Math . round ( ( outlineSize . getHeight ( ) - gh * newScale ) / 2 ) ; if ( magnifyPage ) { dx -= Math . round ( trans . getX ( ) * newScale * graphScale ) ; dy -= Math . round ( trans . getY ( ) * newScale * graphScale ) ; } } } if ( newScale != scale || translate . x != dx || translate . y != dy ) { scale = newScale ; translate . setLocation ( dx , dy ) ; return true ; } else { return false ; } }
Returns true if the scale or translate has changed.
Returns true if the scale or translate has changed .