/** * Reinitializes the insets parameter with this Border's current Insets. * * @param c the component for which this border insets value applies * @param insets the object to be reinitialized * @return the <code>insets</code> object */ public Insets getBorderInsets(Component c, Insets insets) { insets.bottom = this.insets.bottom; insets.top = this.insets.top; insets.left = this.insets.left; insets.right = this.insets.right; return insets; }
/** * Adds a radio button group. * * @param label group label (or null) * @param items radio button labels * @param rows number of rows * @param columns number of columns * @param defaultItem button initially selected */ public void addRadioButtonGroup( String label, String[] items, int rows, int columns, String defaultItem) { Panel panel = new Panel(); int n = items.length; panel.setLayout(new GridLayout(rows, columns, 0, 0)); CheckboxGroup cg = new CheckboxGroup(); for (int i = 0; i < n; i++) { Checkbox cb = new Checkbox(items[i], cg, items[i].equals(defaultItem)); cb.addItemListener(this); panel.add(cb); } if (radioButtonGroups == null) radioButtonGroups = new Vector(); radioButtonGroups.addElement(cg); Insets insets = getInsets(5, 10, 0, 0); if (label == null || label.equals("")) { label = "rbg" + radioButtonGroups.size(); insets.top += 5; } else { setInsets(10, insets.left, 0); addMessage(label); insets.top = 2; insets.left += 10; } c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(insets.top, insets.left, 0, 0); grid.setConstraints(panel, c); add(panel); if (Recorder.record || macro) saveLabel(cg, label); y++; }
@Override public Insets getBorderInsets(Component c) { Dimension size = comp.getPreferredSize(); Insets insets = border.getBorderInsets(c); insets.top = Math.max(insets.top, size.height); return insets; }
public Insets getBorderInsets(Component c, Insets borderInsets) { borderInsets.left = insets.left; borderInsets.top = insets.top; borderInsets.right = insets.right; borderInsets.bottom = insets.bottom; return borderInsets; }
/** * The padding between the "content area" (that is, the icon rect and text rect) and the edges of * this button. This is a calculated value. */ protected Insets getContentInsets(AbstractButton button) { int horizontalPosition = getHorizontalPosition(button); int verticalPosition = getVerticalPosition(button); Insets i = new Insets(0, 0, 0, 0); if (getFocusPainting(button) == PaintFocus.OUTSIDE || getFocusPainting(button) == PaintFocus.BOTH) { if (horizontalPosition == POS_LEFT || horizontalPosition == POS_ONLY) { i.left += focusSize; } if (horizontalPosition == POS_RIGHT || horizontalPosition == POS_ONLY) { i.right += focusSize; } if (verticalPosition == POS_TOP || verticalPosition == POS_ONLY) { i.top += focusSize; } if (verticalPosition == POS_BOTTOM || verticalPosition == POS_ONLY) { i.bottom += focusSize; } } else { if (fill.getShadowHighlight(button) != null && (verticalPosition == POS_BOTTOM || verticalPosition == POS_ONLY)) { i.bottom++; } } return i; }
@Override Insets getNativeInsets() { Insets insets = getInsets(); insets.bottom += hAdjustable.getBounds().height; insets.right += vAdjustable.getBounds().width; return insets; }
public RoundedShadowBorder() { insets = new Insets(0, 0, 0, 0); insets.bottom = bottomLeftCorner.getIconHeight() + backgroundThickness; insets.top = topLeftCorner.getIconHeight() + backgroundThickness; insets.left = topLeftCorner.getIconHeight() + backgroundThickness; insets.right = topRightCorner.getIconHeight() + backgroundThickness; }
public Insets getInsets() { Insets in = copy(getRealInsets()); in.top += getMenuBarHeight() + getWarningWindowHeight(); if (insLog.isLoggable(Level.FINEST)) { insLog.log(Level.FINEST, "Get insets returns {0}", new Object[] {String.valueOf(in)}); } return in; }
@Override public Insets getInsets() { Insets insets = super.getInsets(); if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel() && isEditable) { insets.right += 2; } return insets; }
private Insets getSeparatorInsets(SynthContext context, Insets insets) { int horizPadding = 0; if (context.getRegion() == Region.POPUP_MENU_SEPARATOR) { horizPadding = getClassSpecificIntValue(context, "horizontal-padding", 3); } insets.right = insets.left = getXThickness() + horizPadding; insets.top = insets.bottom = getYThickness(); return insets; }
private Insets getVisualMargin(JComponent component) { String uid = component.getUIClassID(); String style = null; if (uid == "ButtonUI" || uid == "ToggleButtonUI") { style = (String) component.getClientProperty("JButton.buttonType"); } else if (uid == "ProgressBarUI") { style = (((JProgressBar) component).getOrientation() == JProgressBar.HORIZONTAL) ? "horizontal" : "vertical"; } else if (uid == "SliderUI") { style = (((JSlider) component).getOrientation() == JProgressBar.HORIZONTAL) ? "horizontal" : "vertical"; } else if (uid == "TabbedPaneUI") { switch (((JTabbedPane) component).getTabPlacement()) { case JTabbedPane.TOP: style = "top"; break; case JTabbedPane.LEFT: style = "left"; break; case JTabbedPane.BOTTOM: style = "bottom"; break; case JTabbedPane.RIGHT: style = "right"; break; } } Insets gap = getInsets(VISUAL_MARGINS, uid, style, 0); // Take into account different positions of the button icon if (uid == "RadioButtonUI" || uid == "CheckBoxUI") { switch (((AbstractButton) component).getHorizontalTextPosition()) { case SwingConstants.RIGHT: gap = new Insets(gap.top, gap.right, gap.bottom, gap.left); break; case SwingConstants.CENTER: gap = new Insets(gap.top, gap.right, gap.bottom, gap.right); break; /* case SwingConstants.LEFT : break; */ default: gap = new Insets(gap.top, gap.left, gap.bottom, gap.right); } if (component.getBorder() instanceof EmptyBorder) { gap.left -= 2; gap.right -= 2; gap.top -= 2; gap.bottom -= 2; } } return gap; }
@Override public Insets getInsets() { Insets insets = super.getInsets(); if (UIUtil.isUnderGTKLookAndFeel() || UIUtil.isUnderNimbusLookAndFeel()) { insets.top += 1; insets.bottom += 2; } return insets; }
private Insets getMenuBarInsets(SynthContext context, Insets insets) { // The following calculations are derived from gtkmenubar.c // (GTK+ version 2.8.20), gtk_menu_bar_size_allocate() method. int internalPadding = getClassSpecificIntValue(context, "internal-padding", 1); int xThickness = getXThickness(); int yThickness = getYThickness(); insets.left = insets.right = xThickness + internalPadding; insets.top = insets.bottom = yThickness + internalPadding; return insets; }
private Insets getMenuItemInsets(SynthContext context, Insets insets) { // The following calculations are derived from gtkmenuitem.c // (GTK+ version 2.8.20), gtk_menu_item_size_allocate() method. int horizPadding = getClassSpecificIntValue(context, "horizontal-padding", 3); int xThickness = getXThickness(); int yThickness = getYThickness(); insets.left = insets.right = xThickness + horizPadding; insets.top = insets.bottom = yThickness; return insets; }
private Insets getTabbedPaneTabInsets(SynthContext context, Insets insets) { int xThickness = getXThickness(); int yThickness = getYThickness(); int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1); int pad = 2; insets.left = insets.right = focusSize + pad + xThickness; insets.top = insets.bottom = focusSize + pad + yThickness; return insets; }
/** * Layout the receiver. This method set insideBounds & insets according to bounds. Insets is * borderWidth + spacing. * * @see updateDrawableBounds */ protected void layoutComponent() { Insets in = (Insets) getInsets().clone(); in.top += spacing.top; in.left += spacing.left; in.bottom += spacing.bottom; in.right += spacing.right; Dimension d = getSize(); insideBounds.setBounds( in.left, in.top, d.width - in.left - in.right, d.height - in.top - in.bottom); updateDrawableBounds(); }
@Override public Insets getBorderInsets(Component c, Insets insets) { if (insets == null) { return new Insets( this.insets.top, this.insets.left, this.insets.bottom, this.insets.right); } insets.top = this.insets.top; insets.bottom = this.insets.bottom; insets.left = this.insets.left; insets.right = this.insets.left; return insets; }
private Insets getButtonInsets(SynthContext context, Insets insets) { // The following calculations are derived from gtkbutton.c // (GTK+ version 2.8.20), gtk_button_size_allocate() method. int CHILD_SPACING = 1; int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1); int focusPad = getClassSpecificIntValue(context, "focus-padding", 1); int xThickness = getXThickness(); int yThickness = getYThickness(); int w = focusSize + focusPad + xThickness + CHILD_SPACING; int h = focusSize + focusPad + yThickness + CHILD_SPACING; insets.left = insets.right = w; insets.top = insets.bottom = h; Component component = context.getComponent(); if ((component instanceof JButton) && !(component.getParent() instanceof JToolBar) && ((JButton) component).isDefaultCapable()) { // Include the default border insets, but only for JButtons // that are default capable. Note that // JButton.getDefaultCapable() returns true by default, but // GtkToolButtons are never default capable, so we skip this // step if the button is contained in a toolbar. Insets defaultInsets = getClassSpecificInsetsValue(context, "default-border", BUTTON_DEFAULT_BORDER_INSETS); insets.left += defaultInsets.left; insets.right += defaultInsets.right; insets.top += defaultInsets.top; insets.bottom += defaultInsets.bottom; } return insets; }
protected void paintBackgroundSafely(final Graphics g) { final JTextComponent c = getComponent(); final int width = c.getWidth(); final int height = c.getHeight(); // a delegate takes precedence if (delegate != null) { delegate.paint(c, g, 0, 0, width, height); return; } final boolean isOpaque = c.isOpaque(); if (!(c.getBorder() instanceof AquaTextFieldBorder)) { // developer must have set a custom border if (!isOpaque && AquaUtils.hasOpaqueBeenExplicitlySet(c)) return; // must fill whole region with background color if opaque g.setColor(c.getBackground()); g.fillRect(0, 0, width, height); return; } // using our own border g.setColor(c.getBackground()); if (isOpaque) { g.fillRect(0, 0, width, height); return; } final Insets margin = c.getMargin(); Insets insets = c.getInsets(); if (insets == null) insets = new Insets(0, 0, 0, 0); if (margin != null) { insets.top -= margin.top; insets.left -= margin.left; insets.bottom -= margin.bottom; insets.right -= margin.right; } // the common case final int shrinkage = AquaTextFieldBorder.getShrinkageFor(c, height); g.fillRect( insets.left - 2, insets.top - shrinkage - 1, width - insets.right - insets.left + 4, height - insets.bottom - insets.top + shrinkage * 2 + 2); }
/** * Returns a short string representation of this constraints object. This method can use the given * <code>FormLayout</code> to display extra information how default alignments are mapped to * concrete alignments. Therefore it asks the related column and row as specified by this * constraints object. * * @param layout the layout to be presented as a string * @return a short string representation of this constraints object */ public String toShortString(FormLayout layout) { StringBuffer buffer = new StringBuffer("("); buffer.append(formatInt(gridX)); buffer.append(", "); buffer.append(formatInt(gridY)); buffer.append(", "); buffer.append(formatInt(gridWidth)); buffer.append(", "); buffer.append(formatInt(gridHeight)); buffer.append(", \""); buffer.append(hAlign.abbreviation()); if (hAlign == DEFAULT && layout != null) { buffer.append('='); ColumnSpec colSpec = gridWidth == 1 ? layout.getColumnSpec(gridX) : null; buffer.append(concreteAlignment(hAlign, colSpec).abbreviation()); } buffer.append(", "); buffer.append(vAlign.abbreviation()); if (vAlign == DEFAULT && layout != null) { buffer.append('='); RowSpec rowSpec = gridHeight == 1 ? layout.getRowSpec(gridY) : null; buffer.append(concreteAlignment(vAlign, rowSpec).abbreviation()); } buffer.append("\""); if (!(EMPTY_INSETS.equals(insets))) { buffer.append(", "); buffer.append(insets); } buffer.append(')'); return buffer.toString(); }
@Override public Insets getBorderInsets(Component c, final Insets insets) { insets.top += getTitledSeparator(c).getPreferredSize().getHeight() - TitledSeparator.TOP_INSET - TitledSeparator.BOTTOM_INSET; insets.top += UIUtil.DEFAULT_VGAP; insets.top += insideInsets.top; insets.left += insideInsets.left; insets.bottom += insideInsets.bottom; insets.right += insideInsets.right; insets.top += outsideInsets.top; insets.left += outsideInsets.left; insets.bottom += outsideInsets.bottom; insets.right += outsideInsets.right; return insets; }
@Override public void onComputeInsets(Insets outInsets) { super.onComputeInsets(outInsets); if (mState != STATE_IDLE) { outInsets.contentInsets.top = mBottomContent.getTop(); outInsets.touchableInsets = Insets.TOUCHABLE_INSETS_CONTENT; } }
/** * Sets the component's bounds using the given component and cell bounds. * * @param c the component to set bounds * @param layout the FormLayout instance that computes the bounds * @param cellBounds the cell's bounds * @param minWidthMeasure measures the minimum width * @param minHeightMeasure measures the minimum height * @param prefWidthMeasure measures the preferred width * @param prefHeightMeasure measures the preferred height */ void setBounds( Control c, FormLayout layout, Rectangle cellBounds, FormLayout.Measure minWidthMeasure, FormLayout.Measure minHeightMeasure, FormLayout.Measure prefWidthMeasure, FormLayout.Measure prefHeightMeasure) { ColumnSpec colSpec = gridWidth == 1 ? layout.getColumnSpec(gridX) : null; RowSpec rowSpec = gridHeight == 1 ? layout.getRowSpec(gridY) : null; Alignment concreteHAlign = concreteAlignment(this.hAlign, colSpec); Alignment concreteVAlign = concreteAlignment(this.vAlign, rowSpec); Insets concreteInsets = this.insets != null ? this.insets : EMPTY_INSETS; int cellX = cellBounds.x + concreteInsets.getLeft(); int cellY = cellBounds.y + concreteInsets.getTop(); int cellW = cellBounds.width - concreteInsets.getLeft() - concreteInsets.getRight(); int cellH = cellBounds.height - concreteInsets.getTop() - concreteInsets.getBottom(); int compW = componentSize(c, colSpec, cellW, minWidthMeasure, prefWidthMeasure); int compH = componentSize(c, rowSpec, cellH, minHeightMeasure, prefHeightMeasure); int x = origin(concreteHAlign, cellX, cellW, compW); int y = origin(concreteVAlign, cellY, cellH, compH); int w = extent(concreteHAlign, cellW, compW); int h = extent(concreteVAlign, cellH, compH); c.setBounds(x, y, w, h); }
public void configure(PropertySheetTable table, Item item) { isProperty = item.isProperty(); toggleState = item.isVisible(); showToggle = item.hasToggle(); indentWidth = getIndent(table, item); insets.left = indentWidth + (showToggle ? HOTSPOT_SIZE : 0) + 2; ; }
/** * Request the window insets from the delegate and compares it with the current one. This method * is mostly called by the delegate, e.g. when the window state is changed and insets should be * recalculated. * * <p>This method may be called on the toolkit thread. */ public final boolean updateInsets(final Insets newInsets) { synchronized (getStateLock()) { if (insets.equals(newInsets)) { return false; } insets = newInsets; } return true; }
public static Insets add(Insets insets1, Insets insets2) { if (insets1 == null) { return insets2; } else if (insets2 == null) { return insets1; } return new Insets( insets1.getTop() + insets2.getTop(), insets1.getRight() + insets2.getRight(), insets1.getBottom() + insets2.getBottom(), insets1.getLeft() + insets2.getLeft()); }
// NOTE: this is called for ComboBox, and FormattedTextField also private Insets getTextFieldInsets(SynthContext context, Insets insets) { insets = getClassSpecificInsetsValue(context, "inner-border", getSimpleInsets(context, insets, 2)); int xThickness = getXThickness(); int yThickness = getYThickness(); boolean interiorFocus = getClassSpecificBoolValue(context, "interior-focus", true); int focusSize = 0; if (!interiorFocus) { focusSize = getClassSpecificIntValue(context, "focus-line-width", 1); } insets.left += focusSize + xThickness; insets.right += focusSize + xThickness; insets.top += focusSize + yThickness; insets.bottom += focusSize + yThickness; return insets; }
/** * Creates a copy of this cell constraints object. * * @return a copy of this cell constraints object */ public Object clone() { try { CellConstraints c = (CellConstraints) super.clone(); c.insets = (Insets) insets.clone(); return c; } catch (CloneNotSupportedException e) { // This shouldn't happen, since we are Cloneable. throw new InternalError(); } }
private void updateTabBorder() { if (!myProject.isOpen()) return; ToolWindowManagerEx mgr = (ToolWindowManagerEx) ToolWindowManager.getInstance(myProject); String[] ids = mgr.getToolWindowIds(); Insets border = new Insets(0, 0, 0, 0); UISettings uiSettings = UISettings.getInstance(); List<String> topIds = mgr.getIdsOn(ToolWindowAnchor.TOP); List<String> bottom = mgr.getIdsOn(ToolWindowAnchor.BOTTOM); List<String> rightIds = mgr.getIdsOn(ToolWindowAnchor.RIGHT); List<String> leftIds = mgr.getIdsOn(ToolWindowAnchor.LEFT); if (!uiSettings.HIDE_TOOL_STRIPES) { border.top = topIds.size() > 0 ? 1 : 0; border.bottom = bottom.size() > 0 ? 1 : 0; border.left = leftIds.size() > 0 ? 1 : 0; border.right = rightIds.size() > 0 ? 1 : 0; } for (String each : ids) { ToolWindow eachWnd = mgr.getToolWindow(each); if (!eachWnd.isAvailable()) continue; if (eachWnd.isVisible() && eachWnd.getType() == ToolWindowType.DOCKED) { ToolWindowAnchor eachAnchor = eachWnd.getAnchor(); if (eachAnchor == ToolWindowAnchor.TOP) { border.top = 0; } else if (eachAnchor == ToolWindowAnchor.BOTTOM) { border.bottom = 0; } else if (eachAnchor == ToolWindowAnchor.LEFT) { border.left = 0; } else if (eachAnchor == ToolWindowAnchor.RIGHT) { border.right = 0; } } } myTabs .getPresentation() .setPaintBorder(border.top, border.left, border.right, border.bottom) .setTabSidePaintBorder(5); }
/** * @hide Compute the interesting insets into your UI. The default implementation uses the entire * window frame as the insets. The default touchable insets are {@link * Insets#TOUCHABLE_INSETS_FRAME}. * @param outInsets Fill in with the current UI insets. */ @SystemApi public void onComputeInsets(Insets outInsets) { int[] loc = mTmpLocation; View decor = getWindow().getWindow().getDecorView(); decor.getLocationInWindow(loc); outInsets.contentInsets.top = 0; outInsets.contentInsets.left = 0; outInsets.contentInsets.right = 0; outInsets.contentInsets.bottom = 0; outInsets.touchableInsets = Insets.TOUCHABLE_INSETS_FRAME; outInsets.touchableRegion.setEmpty(); }