/**
  * Returns the proper column specification for the given component orientation. The column
  * specification is provided in left-to-right format. When the orientation is left-to-right, the
  * string is returned as is. Otherwise the string is reworked to represent right-to-left.
  *
  * @param leftToRightColSpec The column specification for a left-to-right orientation.
  * @param orientation The orientation of the locale.
  * @return The proper column specification.
  */
 public static String getColSpec(String leftToRightColSpec, ComponentOrientation orientation) {
   if (orientation.isLeftToRight()) {
     return leftToRightColSpec;
   } else {
     return FormLayoutUtil.flip(leftToRightColSpec);
   }
 }
 /**
  * Returns the proper cell constraints for the given column specification and orientation. This
  * means that when the orientation is left-to-right, the cell constraints are returned as is. When
  * it is right-to-left, the cell constraints are flipped horizontally.
  *
  * @param cc The cell constraints defined in left-to-right format.
  * @param colSpec The column specification for which the cell constraints are designed.
  * @param orientation The orientation of the locale.
  * @return The proper cell constraints.
  */
 public static CellConstraints flip(
     CellConstraints cc, String colSpec, ComponentOrientation orientation) {
   if (orientation.isLeftToRight()) {
     return cc;
   } else {
     int columnCount = colSpec.split(",").length;
     return flipHorizontally(cc, columnCount);
   }
 }
  /**
   * Constructs an instance of <code>AbstractFormBuilder</code> for the given FormLayout and layout
   * container.
   *
   * @param layout the {@link FormLayout} to use
   * @param container the layout container
   * @throws NullPointerException if the layout or container is null
   */
  public AbstractFormBuilder(FormLayout layout, Container container) {
    if (layout == null) throw new NullPointerException("The layout must not be null.");

    if (container == null) throw new NullPointerException("The layout container must not be null.");

    this.container = container;
    this.layout = layout;

    container.setLayout(layout);
    currentCellConstraints = new CellConstraints();
    ComponentOrientation orientation = container.getComponentOrientation();
    leftToRight = orientation.isLeftToRight() || !orientation.isHorizontal();
  }
Exemple #4
0
  /**
   * Paints this panel.
   *
   * @param g The graphics context.
   */
  protected void paintComponent(Graphics g) {

    super.paintComponent(g);

    Dimension dim = getSize();
    Color c1 = UIManager.getColor("Label.disabledShadow");
    Color c2 = UIManager.getColor("Label.disabledForeground");

    if (osxSizeGrip != null) {
      g.drawImage(osxSizeGrip, dim.width - 16, dim.height - 16, null);
      return;
    }

    ComponentOrientation orientation = getComponentOrientation();

    if (orientation.isLeftToRight()) {
      int width = dim.width -= 3;
      int height = dim.height -= 3;
      g.setColor(c1);
      g.fillRect(width - 9, height - 1, 3, 3);
      g.fillRect(width - 5, height - 1, 3, 3);
      g.fillRect(width - 1, height - 1, 3, 3);
      g.fillRect(width - 5, height - 5, 3, 3);
      g.fillRect(width - 1, height - 5, 3, 3);
      g.fillRect(width - 1, height - 9, 3, 3);
      g.setColor(c2);
      g.fillRect(width - 9, height - 1, 2, 2);
      g.fillRect(width - 5, height - 1, 2, 2);
      g.fillRect(width - 1, height - 1, 2, 2);
      g.fillRect(width - 5, height - 5, 2, 2);
      g.fillRect(width - 1, height - 5, 2, 2);
      g.fillRect(width - 1, height - 9, 2, 2);
    } else {
      int height = dim.height -= 3;
      g.setColor(c1);
      g.fillRect(10, height - 1, 3, 3);
      g.fillRect(6, height - 1, 3, 3);
      g.fillRect(2, height - 1, 3, 3);
      g.fillRect(6, height - 5, 3, 3);
      g.fillRect(2, height - 5, 3, 3);
      g.fillRect(2, height - 9, 3, 3);
      g.setColor(c2);
      g.fillRect(10, height - 1, 2, 2);
      g.fillRect(6, height - 1, 2, 2);
      g.fillRect(2, height - 1, 2, 2);
      g.fillRect(6, height - 5, 2, 2);
      g.fillRect(2, height - 5, 2, 2);
      g.fillRect(2, height - 9, 2, 2);
    }
  }
Exemple #5
0
    private Icon getIcon(SynthContext context) {
      if (context != null) {
        ComponentOrientation co = context.getComponent().getComponentOrientation();
        SynthStyle style = context.getStyle();

        if (style != this.style) {
          this.style = style;
          loadedLTR = loadedRTL = false;
        }
        if (co == null || co.isLeftToRight()) {
          if (!loadedLTR) {
            loadedLTR = true;
            ltrIcon = ((GTKStyle) context.getStyle()).getStockIcon(context, key, size);
          }
          return ltrIcon;
        } else if (!loadedRTL) {
          loadedRTL = true;
          rtlIcon = ((GTKStyle) context.getStyle()).getStockIcon(context, key, size);
        }
        return rtlIcon;
      }
      return ltrIcon;
    }
Exemple #6
0
  private Icon getStockIcon(SynthContext context, String key, int type) {
    TextDirection direction = TextDirection.LTR;

    if (context != null) {
      ComponentOrientation co = context.getComponent().getComponentOrientation();

      if (co != null && !co.isLeftToRight()) {
        direction = TextDirection.RTL;
      }
    }

    // First try loading a theme-specific icon using the native
    // GTK libraries (native GTK handles the resizing for us).
    Icon icon = getStyleSpecificIcon(key, direction, type);
    if (icon != null) {
      return icon;
    }

    // In a failure case where native GTK (unexpectedly) returns a
    // null icon, we can try loading a default icon as a fallback.
    String propName =
        ICON_PROPERTY_PREFIX
            + key
            + '.'
            + type
            + '.'
            + (direction == TextDirection.RTL ? "rtl" : "ltr");
    Image img = (Image) Toolkit.getDefaultToolkit().getDesktopProperty(propName);
    if (img != null) {
      return new ImageIcon(img);
    }

    // In an extreme failure situation, just return null (callers are
    // already prepared to handle a null icon, so the worst that can
    // happen is that an icon won't be included in the button/dialog).
    return null;
  }
 void setComponentOrientation(ComponentOrientation orientation) {
   horizontal = orientation.isHorizontal();
   leftToRight = orientation.isLeftToRight();
 }
Exemple #8
0
 /**
  * Overridden to ensure that the cursor for this component is appropriate for the orientation.
  *
  * @param o The new orientation.
  */
 public void applyComponentOrientation(ComponentOrientation o) {
   possiblyFixCursor(o.isLeftToRight());
   super.applyComponentOrientation(o);
 }