java.awt.Dimension Java Examples

The following examples show how to use java.awt.Dimension. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EditorPane.java    From 3Dscript with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
	 * @return this EditorPane wrapped in a {@link RTextScrollPane}.
	 */
	public RTextScrollPane wrappedInScrollbars() {
		final RTextScrollPane sp = new RTextScrollPane(this);
		sp.setPreferredSize(new Dimension(600, 350));
		sp.setIconRowHeaderEnabled(true);

		gutter = sp.getGutter();
//		iconGroup = new IconGroup("bullets", "images/", null, "png", null);
//		gutter.setBookmarkIcon(iconGroup.getIcon("var"));

//		URL url = ClassLoader.getSystemClassLoader().getResource("eye.png");
//		ImageIcon icon = new ImageIcon(url);
//		gutter.setBookmarkIcon(icon);
//		gutter.setBookmarkingEnabled(true);

		return sp;
	}
 
Example #2
Source File: PushTransition2D.java    From Pixelitor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Transition2DInstruction[] getInstructions(float progress, Dimension size) {
    AffineTransform transform1 = new AffineTransform();
    AffineTransform transform2 = new AffineTransform();

    if (type == LEFT) {
        transform2.translate(size.width * (1 - progress), 0);
        transform1.translate(size.width * (1 - progress) - size.width, 0);
    } else if (type == RIGHT) {
        transform2.translate(size.width * (progress - 1), 0);
        transform1.translate(size.width * (progress - 1) + size.width, 0);
    } else if (type == UP) {
        transform2.translate(0, size.height * (1 - progress));
        transform1.translate(0, size.height * (1 - progress) - size.height);
    } else {
        transform2.translate(0, size.height * (progress - 1));
        transform1.translate(0, size.height * (progress - 1) + size.height);
    }

    return new Transition2DInstruction[]{
            new ImageInstruction(true, transform1, null),
            new ImageInstruction(false, transform2, null)
    };
}
 
Example #3
Source File: Test7163696.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void run() {
    if (this.bar == null) {
        this.bar = new JScrollBar(JScrollBar.HORIZONTAL, 50, 10, 0, 100);
        this.bar.setPreferredSize(new Dimension(400, 20));

        JFrame frame = new JFrame();
        frame.add(this.bar);
        frame.pack();
        frame.setVisible(true);
    }
    else if (40 != this.bar.getValue()) {
        System.out.println("name = " + UIManager.getLookAndFeel().getName());
        System.out.println("value = " + this.bar.getValue());
    }
    else {
        SwingUtilities.getWindowAncestor(this.bar).dispose();
        this.bar = null;
    }
}
 
Example #4
Source File: Utilities.java    From javamelody with Apache License 2.0 6 votes vote down vote up
/**
 * Fixe la taille exacte d'une JTable à celle nécessaire pour afficher les données.
 * @param table JTable
 */
public static void adjustTableHeight(final JTable table) {
	table.setPreferredScrollableViewportSize(
			new Dimension(-1, table.getPreferredSize().height));
	// on utilise invokeLater pour configurer le scrollPane car lors de l'exécution ce cette méthode
	// la table n'est pas encore dans son scrollPane parent
	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			final JScrollPane scrollPane = MSwingUtilities.getAncestorOfClass(JScrollPane.class,
					table);
			scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
			// Puisqu'il n'y a pas d'ascenceur sur ce scrollPane,
			// il est inutile que la mollette de souris serve à bouger cet ascenseur,
			// mais il est très utile en revanche que ce scrollPane ne bloque pas l'utilisation
			// de la mollette de souris pour le scrollPane global de l'onglet principal.
			// On commence par enlever le listener au cas où la méthode soit appelée deux fois sur la même table.
			scrollPane.removeMouseWheelListener(DELEGATE_TO_PARENT_MOUSE_WHEEL_LISTENER);
			scrollPane.addMouseWheelListener(DELEGATE_TO_PARENT_MOUSE_WHEEL_LISTENER);
		}
	});
}
 
Example #5
Source File: JMapViewer.java    From Course_Generator with GNU General Public License v3.0 6 votes vote down vote up
public JMapViewer(TileCache tileCache, int downloadThreadCount) {
	super();
	JobDispatcher.setMaxWorkers(downloadThreadCount);
	tileSource = new OsmTileSource.Mapnik();
	tileController = new TileController(tileSource, tileCache, this);
	mapMarkerList = new LinkedList<>();
	mapPolygonList = new LinkedList<>();
	mapRectangleList = new LinkedList<>();
	mapMarkersVisible = true;
	mapRectanglesVisible = true;
	mapPolygonsVisible = true;
	tileGridVisible = false;
	setLayout(null);
	initializeZoomSlider();
	setMinimumSize(new Dimension(tileSource.getTileSize(), tileSource.getTileSize()));
	setPreferredSize(new Dimension(400, 400));
	setDisplayPosition(new Coordinate(50, 9), 3);
	// setToolTipText("");
}
 
Example #6
Source File: ImageViewer.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Opens a JDialog with the image viewer in it.
 * 
 * @param image the image to show.
 * @param title the title of the dialog.
 * @param modal if <code>true</code>, the dialog is modal.
 */
public static void show( BufferedImage image, String title, boolean modal ) {
    JDialog f = new JDialog();
    f.add(new ImageViewer(image), BorderLayout.CENTER);
    f.setTitle(title);
    f.setIconImage(ImageCache.getInstance().getBufferedImage(ImageCache.HORTONMACHINE_FRAME_ICON));
    f.setModal(modal);
    f.pack();
    int h = image.getHeight();
    int w = image.getWidth();
    if (h > w) {
        f.setSize(new Dimension(600, 800));
    } else {
        f.setSize(new Dimension(800, 600));
    }
    f.setLocationRelativeTo(null); // Center on screen
    f.setVisible(true);
    f.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    f.getRootPane().registerKeyboardAction(e -> {
        f.dispose();
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
}
 
Example #7
Source File: LogFileViewer.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Inits the.
 *
 * @param file the file
 * @param d the d
 */
public void init(File file, Dimension d) {
	createMenus();
	this.logFile = file;
	this.textArea = new JTextArea();
	// Copy
	Action copyAction = this.textArea.getActionMap().get(DefaultEditorKit.copyAction);
	copyAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C,
			InputEvent.CTRL_MASK));
	copyAction.setEnabled(true);
	this.scrollPane = new JScrollPane(this.textArea);
	this.setContentPane(this.scrollPane);
	this.scrollPane.setPreferredSize(d);
	boolean doneLoadingFile = loadFile();
	if (!doneLoadingFile) {
		this.dispose();
		return;
	}
	this.pack();
	this.setVisible(true);
}
 
Example #8
Source File: ErrorPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void btnStackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStackActionPerformed
    StringWriter sw = new StringWriter();
    exception.printStackTrace(new PrintWriter(sw));
    JPanel pnl = new JPanel();
    pnl.setLayout(new BorderLayout());
    pnl.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    JTextArea ta = new JTextArea();
    ta.setText(sw.toString());
    ta.setEditable(false);
    JScrollPane pane = new JScrollPane(ta);
    pnl.add(pane);
    pnl.setMaximumSize(new Dimension(600, 300));
    pnl.setPreferredSize(new Dimension(600, 300));
    NotifyDescriptor.Message nd = new NotifyDescriptor.Message(pnl);
    DialogDisplayer.getDefault().notify(nd);

}
 
Example #9
Source File: FrameTool.java    From FCMFrame with Apache License 2.0 6 votes vote down vote up
/**
   * 屏幕居中方法
   */
  public static void setCenter(JFrame jframe) {
      Toolkit kit = Toolkit.getDefaultToolkit();
      Dimension screenSize = kit.getScreenSize();
      int screenHeight = screenSize.height;
      int screenWidth = screenSize.width;
      jframe.setSize(screenWidth*2/3, screenHeight*2/3);
      int frameH = jframe.getHeight();
      int frameW = jframe.getWidth();
      jframe.setLocation((screenWidth - frameW) / 2, (screenHeight - frameH) / 2);
try {
	String src = "images/logo.gif";
	File f = new File(src);
	Image image = ImageIO.read(f);
	jframe.setIconImage(image);
} catch (IOException e) {
	e.printStackTrace();
}
  }
 
Example #10
Source File: LuckMenuUI.java    From littleluck with Apache License 2.0 6 votes vote down vote up
/**
 * <p>
 * 重写方法,设置菜单的最小高度为20, 否则会出现菜单项大小不一致的情况。
 * </p>
 *
 * <p>
 * Rewrite method, set the minimum height of the menu is 20, otherwise the
 * menu item size will be inconsistent situation.
 * </p>
 */
protected Dimension getPreferredMenuItemSize(JComponent c,
                                             Icon checkIcon,
                                             Icon arrowIcon,
                                             int defaultTextIconGap)
{
    Dimension dimension = super.getPreferredMenuItemSize(c, checkIcon,
            arrowIcon, defaultTextIconGap);

    if (dimension != null && dimension.height < 20)
    {
        dimension.setSize(dimension.width, 20);
    }

    return dimension;
}
 
Example #11
Source File: WPrinterJob.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
Example #12
Source File: CompletionLayoutPopup.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Sets maximum size for appropriate JComponent, depending on wheteher
 * additional items are present
 */
private void setMaxSize(JComponent comp, Dimension maxSize) {
    if (comp instanceof JPanel) {
        comp.getComponent(0).setMaximumSize(maxSize); // JScrollPane
    } else {
        comp.setMaximumSize(maxSize);
    }
}
 
Example #13
Source File: MultiScrollPaneUI.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Invokes the <code>getPreferredSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getPreferredSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
    }
    return returnValue;
}
 
Example #14
Source File: MultiSeparatorUI.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMaximumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
    }
    return returnValue;
}
 
Example #15
Source File: MultiScrollPaneUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMaximumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
    }
    return returnValue;
}
 
Example #16
Source File: LinesComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void checkSize() {
    int count = getLineCount();
    if (count > highestLineNumber) {
        highestLineNumber = count;
    }
    Dimension dim = getPreferredSize();
    if (getWidthDimension() > dim.width ||
        getHeightDimension() > dim.height) {
            resize();
    }
}
 
Example #17
Source File: MultiPopupMenuUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMaximumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
    }
    return returnValue;
}
 
Example #18
Source File: ImageHeaderBitmap.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public ImageHeaderBitmap(byte data[], int offset) {
    BufferedImage img = null;
    try {
        img = ImageIO.read(new ByteArrayInputStream(data, offset, data.length-offset));
    } catch (IOException e) {
        LOG.log(POILogger.WARN, "Can't determine image dimensions", e);
    }
    // set dummy size, in case of dummy dimension can't be set
    size = (img == null)
        ? new Dimension(200,200)
        : new Dimension(
            (int)Units.pixelToPoints(img.getWidth()),
            (int)Units.pixelToPoints(img.getHeight())
        );
}
 
Example #19
Source File: SquaresTransition2D.java    From pumpernickel with MIT License 5 votes vote down vote up
protected float findMax(float t0, float t1) {
	if (t1 - t0 < .0001)
		return Math.max(t0, t1);

	Rectangle2D r = new Rectangle2D.Float(0, 0, 100, 100);
	float mid = t0 / 2f + t1 / 2f;
	Transition2DInstruction[] instrA = getInstructions(t0, new Dimension(
			100, 100));
	Transition2DInstruction[] instrB = getInstructions(mid, new Dimension(
			100, 100));
	Transition2DInstruction[] instrC = getInstructions(t1, new Dimension(
			100, 100));
	boolean validA = false;
	boolean validB = false;
	boolean validC = false;
	for (int a = 1; a < instrA.length; a++) {
		if (r.intersects((Rectangle2D) ((ImageInstruction) instrA[a]).clipping)) {
			validA = true;
		}
		if (r.intersects((Rectangle2D) ((ImageInstruction) instrB[a]).clipping)) {
			validB = true;
		}
		if (r.intersects((Rectangle2D) ((ImageInstruction) instrC[a]).clipping)) {
			validC = true;
		}
	}
	if (validA && validC)
		return Math.max(t0, t1);
	if (validA) {
		if (validB) {
			return findMax(mid, t1);
		} else {
			return findMax(t0, mid);
		}
	} else {
		throw new RuntimeException();
	}
}
 
Example #20
Source File: MetalScrollBarUI.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Dimension getPreferredSize( JComponent c )
{
    if ( scrollbar.getOrientation() == JScrollBar.VERTICAL )
    {
        return new Dimension( scrollBarWidth, scrollBarWidth * 3 + 10 );
    }
    else  // Horizontal
    {
        return new Dimension( scrollBarWidth * 3 + 10, scrollBarWidth );
    }

}
 
Example #21
Source File: LanderAvatar.java    From GVGAI_GYM with Apache License 2.0 5 votes vote down vote up
public LanderAvatar(Vector2d position, Dimension size, SpriteContent cnt)
{
    //Init the sprite
    this.init(position, size);

    //Specific class default parameter values.
    loadDefaults();

    //Parse the arguments.
    this.parseParameters(cnt);
}
 
Example #22
Source File: BasicToolBarSeparatorUI.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Dimension getPreferredSize( JComponent c )
{
    Dimension size = ( (JToolBar.Separator)c ).getSeparatorSize();

    if ( size != null )
    {
        return size.getSize();
    }
    else
    {
        return null;
    }
}
 
Example #23
Source File: ExtensionTablePanel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor; builds the panel and sets table attributes.
 * 
 * @param tool the tool showing the extension dialog
 */
public ExtensionTablePanel(PluginTool tool) {

	super(new BorderLayout());

	tableModel = new ExtensionTableModel(tool);
	tableModel.setTableSortState(
		TableSortState.createDefaultSortState(ExtensionTableModel.NAME_COL));
	table = new GTable(tableModel);
	table.setPreferredScrollableViewportSize(new Dimension(500, 300));
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	JScrollPane sp = new JScrollPane(table);
	sp.getViewport().setBackground(table.getBackground());
	add(sp, BorderLayout.CENTER);

	tableFilterPanel = new GTableFilterPanel<>(table, tableModel);
	add(tableFilterPanel, BorderLayout.SOUTH);

	HelpService help = Help.getHelpService();
	help.registerHelp(table, new HelpLocation(GenericHelpTopics.FRONT_END, "Extensions"));

	// Restrict the checkbox col to only be 25 pixels wide - the default size is
	// way too large. This is annoying but our table column classes don't have a nice
	// way to restrict column width.
	TableColumn col = table.getColumnModel().getColumn(ExtensionTableModel.INSTALLED_COL);
	col.setMaxWidth(25);

	// Finally, load the table with some data.
	refreshTable();
}
 
Example #24
Source File: MultiScrollBarUI.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMinimumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
    }
    return returnValue;
}
 
Example #25
Source File: PaintAll.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws Exception {
    //Frame initialisation
    final BufferedImage graphicsProducer =
            new BufferedImage(BufferedImage.TYPE_INT_ARGB, 1, 1);

    final Graphics g = graphicsProducer.getGraphics();

    frame.setLayout(new GridLayout());
    frame.add(buttonStub);
    frame.add(canvasStub);
    frame.add(checkboxStub);
    frame.add(choiceStub);
    frame.add(lwComponentStub);
    frame.add(containerStub);
    frame.add(labelStub);
    frame.add(listStub);
    frame.add(panelStub);
    frame.add(scrollbarStub);
    frame.add(scrollPaneStub);
    frame.add(textAreaStub);
    frame.add(textFieldStub);
    frame.setSize(new Dimension(500, 500));
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();

    //Check results.
    validation();

    //Reset all flags to 'false'.
    initPaintedFlags();

    //Tested method.
    frame.paintAll(g);
    sleep();

    //Check results.
    validation();
    cleanup();
}
 
Example #26
Source File: SystemAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Create an icon.
* @param comp a component, which must be unattached to a container
*             and should not be used for other purposes
*/
public ComponentIcon(JComponent comp) {
    if (comp.getParent() != null) {
        throw new IllegalArgumentException();
    }

    this.comp = comp;

    Dimension size = comp.getPreferredSize();

    // Careful! If you have e.g. a JLabel with empty text, width = 0 => exceptions.
    // Must make sure it is at least a reasonable size.
    comp.setSize(Math.max(size.width, 16), Math.max(size.height, 16));
}
 
Example #27
Source File: JavaHelp.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void init(Runnable run) {
    this.run = run;
    JComponent c = ProgressHandleFactory.createProgressComponent(progressHandle);
    c.setPreferredSize(new Dimension(3 * c.getPreferredSize().width, 3 * c.getPreferredSize().height));
    c.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
    getContentPane().add(c);
    progressHandle.start();
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(JavaHelp.class, "ACSD_Loading_Dialog"));  //NOI18N
    pack();
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension me = getSize();
    setLocation((screen.width - me.width) / 2, (screen.height - me.height) / 2);
}
 
Example #28
Source File: GraphicUtils.java    From xyTalk-pc with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
    * Centers the window over a component (usually another window). The window
    * must already have been sized.
    * 
    * @param window
    *            Window to center.
    * @param over
    *            Component to center over.
    */
   public static void centerWindowOnComponent(Window window, Component over) {
if ((over == null) || !over.isShowing()) {
    centerWindowOnScreen(window);
    return;
}

Point parentLocation = over.getLocationOnScreen();
Dimension parentSize = over.getSize();
Dimension size = window.getSize();

// Center it.
int x = parentLocation.x + (parentSize.width - size.width) / 2;
int y = parentLocation.y + (parentSize.height - size.height) / 2;

// Now, make sure it's onscreen
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

// This doesn't actually work on the Mac, where the screen
// doesn't necessarily start at 0,0
if (x + size.width > screenSize.width)
    x = screenSize.width - size.width;

if (x < 0)
    x = 0;

if (y + size.height > screenSize.height)
    y = screenSize.height - size.height;

if (y < 0)
    y = 0;

window.setLocation(x, y);
   }
 
Example #29
Source File: ProcessingComponent.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
public ProcessingComponent() {
  super(new BorderLayout());

  setPreferredSize(new Dimension(600, 400));

  cbDiffMSn = GUIUtils.addCheckbox(this,
      "Use different settings for " + MSLevel.MSONE.toString() + " and "
          + MSLevel.MSMS.toString(),
      this, "CBX_DIFFMSN",
      "If enabled, MS^1 and MS^n processing will use different parameters. The currently used settings are highlighted in green.");
  cbDiffMSn.setSelected(
      DataPointProcessingManager.getInst().getProcessingParameters().isDifferentiateMSn());

  add(cbDiffMSn, BorderLayout.NORTH);

  setupTreeViews();
  split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tvProcessing, tvAllModules);
  initTreeListeners();
  add(split, BorderLayout.CENTER);
  split.setDividerLocation(300);

  buttonPanel = new JPanel(new FlowLayout());
  GUIUtils.addButton(buttonPanel, "Add", null, this, "BTN_ADD");
  GUIUtils.addButton(buttonPanel, "Remove", null, this, "BTN_REMOVE");
  GUIUtils.addButton(buttonPanel, "Set parameters", null, this, "BTN_SET_PARAMETERS");
  GUIUtils.addButton(buttonPanel, "Load", null, this, "BTN_LOAD");
  GUIUtils.addButton(buttonPanel, "Save", null, this, "BTN_SAVE");
  // GUIUtils.addButton(buttonPanel, "Set Default...", null, this, "BTN_SET_DEFAULT");
  add(buttonPanel, BorderLayout.SOUTH);

  chooser = new LoadSaveFileChooser("Select Processing Queue File");
  chooser.addChoosableFileFilter(new FileNameExtensionFilter("XML files", XML_EXTENSION));

  super.repaint();
}
 
Example #30
Source File: GLRenderer.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
    final GL3 gl = drawable.getGL().getGL3();

    //  Windows-DPI-Scaling
    //
    // If JOGL is ever fixed or another solution is found, either change
    // needsManualDPIScaling to return false (so there is effectively no
    // DPI scaling here) or remove the scaled height and width below.         
    float dpiScaleX = 1.0f;
    float dpiScaleY = 1.0f;
    if (GLTools.needsManualDPIScaling()) {
        dpiScaleX = (float) ((Graphics2D) (parent.canvas).getGraphics()).getTransform().getScaleX();
        dpiScaleY = (float) ((Graphics2D) (parent.canvas).getGraphics()).getTransform().getScaleY();
    }

    // These need to be final as they are used in the lambda function below
    final int dpiScaledWidth = (int) (width * dpiScaleX);
    final int dpiScaledHeight = (int) (height * dpiScaleY);

    gl.glViewport(0, 0, dpiScaledWidth, dpiScaledHeight);

    // Create the projection matrix, and load it on the projection matrix stack.
    viewFrustum.setPerspective(FIELD_OF_VIEW, (float) dpiScaledWidth / (float) dpiScaledHeight, PERSPECTIVE_NEAR, PERSPECTIVE_FAR);

    projectionMatrix.set(viewFrustum.getProjectionMatrix());

    // A GLCanvas sets its minimum size to the preferred size when its redrawn. This means it will get bigger,
    // but never get smaller. Explicitly set the minimum size to get around this.
    ((Component) drawable).setMinimumSize(new Dimension(0, 0));

    renderables.forEach(renderable -> {
        renderable.reshape(x, y, dpiScaledWidth, dpiScaledHeight);
    });

    viewport[0] = x;
    viewport[1] = y;
    viewport[2] = dpiScaledWidth;
    viewport[3] = dpiScaledHeight;
}