Android Mirroring/Device Frame/Get Preferred Size
public Dimension getPreferredSize() {^M Dimension frame = super.getPreferredSize();^M Insets fb = super.getInsets();^M Dimension screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getSize();^M Dimension canvasSize = canvas.getPreferredSize();^M Dimension infoPaneSize = infoPane.getSize();^M Dimension toolBarSize = toolBar.getSize();^M ^M log.debug(String.format("getPreferredSize: screen=%s, canvas=%s, frame=%s",^M screen, canvasSize, frame^M ));^M ^M if (frame.height > screen.height) {^M frame.height = (int) (0.9 * screen.height);^M }^M if (frame.width > screen.width) {^M frame.width = (int) (0.9*screen.width);^M }^M ^M JScrollBar vsb = canvasScrollable.getVerticalScrollBar();^M int vsbW = vsb.getWidth(); //vsb.isShowing() ? vsb.getWidth() : 0;^M JScrollBar hsb = canvasScrollable.getHorizontalScrollBar();^M int hsbH = hsb.getHeight(); //hsb.isShowing() ? hsb.getHeight() : 0;^M ^M int W = fb.left + toolBarSize.width + canvasSize.width + vsbW + fb.right;^M int H = fb.top + infoPaneSize.height + canvasSize.height + hsbH + fb.bottom;^M if (frame.width > W) {^M frame.width = W;^M }^M if (frame.height > H) {^M frame.height = H;^M }^M log.debug(String.format("getPreferredSize: frame2=%s", frame));^M ^M return frame;^M }^M
public Dimension getPreferredSize() {^M if (image == null) {^M return new Dimension(200, 300);^M }^M if (landscapeMode) {^M if (skinBackgroundImage != null) {^M return new Dimension(scale(skinBackgroundImage.getHeight(null)), scale(skinBackgroundImage.getWidth(null)));^M }^M return new Dimension(scale(image.getHeight()), scale(image.getWidth()));^M }^M if (skinBackgroundImage != null) {^M return new Dimension(scale(skinBackgroundImage.getWidth(null)), scale(skinBackgroundImage.getHeight(null)));^M }^M return new Dimension(scale(image.getWidth()), scale(image.getHeight()));^M }^M
ÇØ»óµµ¿Í ppi ¶
call ¶
private int scale(int value) {^M double factor = getScaleFactor();^M if (factor != 1) {^M scalePercentage = (int) (factor * 100);^M }^M if (scalePercentage == 100) {^M return value;^M }^M return (int) Math.round(value * scalePercentage / 100.0);^M }^M private double getScaleFactor() {^M final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();^M final double screenHeight = screen.getHeight();^M final double screenWidth = screen.getWidth();^M double factor = 1;^M if (screenHeight <= getHeight()) {^M factor = screenHeight / getHeight();^M if (factor > 0.75) {^M factor = 0.25;^M } else if (factor > 0.50) {^M factor = 0.25;^M } else if (factor > 0.25) {^M factor = 0.25;^M }^M }^M return factor;^M }^M canvas ¶Settings ¶
public int getPreferredScale() {^M return applicationPreferences.getInt("scale", 100);^M }^M ^M public void setPreferredScale(int value) {^M set("scale", value);^M }^M |
If it pours before seven, it has rained by eleven. |