Package org.dyno.visual.swing.layouts

Examples of org.dyno.visual.swing.layouts.LayoutStyle


  }

  private List<Quartet> getTConAnchor(JComponent todrop, Point this_point) {
    Insets insets = container.getInsets();
    int ty = this_point.y;
    LayoutStyle style = LayoutStyle.getInstance();
    int north = style.getContainerGap(todrop, SwingConstants.NORTH, container);
    int w = container.getWidth();
    if (Math.abs(ty - insets.top) < THRESHOLD_DISTANCE) {
      List<Quartet> list = new ArrayList<Quartet>();
      Quartet trio = new Quartet(insets.top, insets.top, insets.left, w - insets.right, new HorizontalLeadingContainerAnchor(container));
      list.add(trio);
View Full Code Here


      return list;
    } else
      return null;
  }
  private List<Quartet> getBAnchor(JComponent todrop, JComponent target, Point this_point) {
    LayoutStyle style = LayoutStyle.getInstance();
    int nr = style.getPreferredGap(todrop, target, ComponentPlacement.RELATED, SwingConstants.NORTH, container);
    int nu = style.getPreferredGap(todrop, target, ComponentPlacement.UNRELATED, SwingConstants.NORTH, container);
    int nm = nr + nu;
    int sr = style.getPreferredGap(todrop, target, ComponentPlacement.RELATED, SwingConstants.SOUTH, container);
    int su = style.getPreferredGap(todrop, target, ComponentPlacement.UNRELATED, SwingConstants.SOUTH, container);
    int sm = sr + su;
    int ty = target.getY();
    int tby = target.getY() + target.getHeight();
    nr = ty - nr;
    nu = ty - nu;
View Full Code Here

  protected Alignment createVerticalLeading(Component me, Rectangle bounds, Container parent) {
    int min = Integer.MIN_VALUE;
    int pref = Integer.MIN_VALUE;
    int count = parent.getComponentCount();
    GroupLayout layout = (GroupLayout) parent.getLayout();
    LayoutStyle layoutStyle = LayoutStyle.getInstance();
    for (int i = 0; i < count; i++) {
      Component target = parent.getComponent(i);
      Constraints constraints = layout.getConstraints(target);
      Rectangle targetBounds = target.getBounds();
      if (constraints != null && isOverlap(bounds.x, bounds.width, targetBounds.x, targetBounds.width)) {
        Alignment vertical = constraints.getVertical();
        Dimension prefs = target.getPreferredSize();
        Dimension mins = target.getMinimumSize();
        if (vertical instanceof Trailing) {
          int gap = layoutStyle.getPreferredGap((JComponent) target, (JComponent) me, ComponentPlacement.UNRELATED, SwingConstants.NORTH, parent);
          Trailing trailing = (Trailing) vertical;
          int pref_size = trailing.getSize() == Alignment.PREFERRED ? prefs.height : trailing.getSize();
          int min_size = pref_size > mins.height ? mins.height : pref_size;
          int actual = gap + min_size + trailing.getTrailing();
          if (actual > min)
            min = actual;
          actual = gap + pref_size + trailing.getTrailing();
          if (actual > pref)
            pref = actual;
        } else if (vertical instanceof Bilateral) {
          int gap = layoutStyle.getPreferredGap((JComponent) target, (JComponent) me, ComponentPlacement.RELATED, SwingConstants.NORTH, parent);
          Bilateral bilateral = (Bilateral) vertical;
          int actual = gap + mins.height + bilateral.getTrailing();
          if (actual > min)
            min = actual;
          actual = gap + prefs.height + bilateral.getTrailing();
          if (actual > pref)
            pref = actual;
        }
      }
    }
    int gap = layoutStyle.getContainerGap((JComponent) me, SwingConstants.SOUTH, parent);
    if (gap > min)
      min = gap;
    if (gap > pref)
      pref = gap;
    Spring spring = new Spring(min, pref);
View Full Code Here

  protected Alignment createVerticalTrailing(Component me, Rectangle bounds, Container parent) {
    int min = Integer.MIN_VALUE;
    int pref = Integer.MIN_VALUE;
    int count = parent.getComponentCount();
    GroupLayout layout = (GroupLayout) parent.getLayout();
    LayoutStyle layoutStyle = LayoutStyle.getInstance();
    for (int i = 0; i < count; i++) {
      Component target = parent.getComponent(i);
      Constraints constraints = layout.getConstraints(target);
      Rectangle targetBounds = target.getBounds();
      if (constraints != null && isOverlap(bounds.x, bounds.width, targetBounds.x, targetBounds.width)) {
        Alignment vertical = constraints.getVertical();
        Dimension prefs = target.getPreferredSize();
        Dimension mins = target.getMinimumSize();
        if (vertical instanceof Leading) {
          int gap = layoutStyle.getPreferredGap((JComponent) target, (JComponent) me, ComponentPlacement.UNRELATED, SwingConstants.SOUTH, parent);
          Leading leading = (Leading) vertical;
          int pref_size = leading.getSize() == Alignment.PREFERRED ? prefs.height : leading.getSize();
          int min_size = pref_size > mins.height ? mins.height : pref_size;
          int actual = gap + min_size + leading.getLeading();
          if (actual > min)
            min = actual;
          actual = gap + pref_size + leading.getLeading();
          if (actual > pref)
            pref = actual;
        } else if (vertical instanceof Bilateral) {
          int gap = layoutStyle.getPreferredGap((JComponent) target, (JComponent) me, ComponentPlacement.RELATED, SwingConstants.SOUTH, parent);
          Bilateral bilateral = (Bilateral) vertical;
          int actual = gap + mins.height + bilateral.getTrailing();
          if (actual > min)
            min = actual;
          actual = gap + prefs.height + bilateral.getTrailing();
          if (actual > pref)
            pref = actual;
        }
      }
    }
    int gap = layoutStyle.getContainerGap((JComponent) me, SwingConstants.NORTH, parent);
    if (gap > min)
      min = gap;
    if (gap > pref)
      pref = gap;
    Spring spring = new Spring(min, pref);
View Full Code Here

  protected Alignment createHorizontalLeading(Component me, Rectangle bounds, Container parent) {
    int min = Integer.MIN_VALUE;
    int pref = Integer.MIN_VALUE;
    int count = parent.getComponentCount();
    GroupLayout layout = (GroupLayout) parent.getLayout();
    LayoutStyle layoutStyle = LayoutStyle.getInstance();
    for (int i = 0; i < count; i++) {
      Component target = parent.getComponent(i);
      Constraints constraints = layout.getConstraints(target);
      Rectangle targetBounds = target.getBounds();
      if (constraints != null && isOverlap(bounds.y, bounds.height, targetBounds.y, targetBounds.height)) {
        Alignment horizontal = constraints.getHorizontal();
        Dimension prefs = target.getPreferredSize();
        Dimension mins = target.getMinimumSize();
        if (horizontal instanceof Trailing) {
          int gap = layoutStyle.getPreferredGap((JComponent) target, (JComponent) me, ComponentPlacement.UNRELATED, SwingConstants.WEST, parent);
          Trailing trailing = (Trailing) horizontal;
          int pref_size = trailing.getSize() == Alignment.PREFERRED ? prefs.width : trailing.getSize();
          int min_size = pref_size > mins.width ? mins.width : pref_size;
          int actual = gap + min_size + trailing.getTrailing();
          if (actual > min)
            min = actual;
          actual = gap + pref_size + trailing.getTrailing();
          if (actual > pref)
            pref = actual;
        } else if (horizontal instanceof Bilateral) {
          int gap = layoutStyle.getPreferredGap((JComponent) target, (JComponent) me, ComponentPlacement.RELATED, SwingConstants.WEST, parent);
          Bilateral bilateral = (Bilateral) horizontal;
          int actual = gap + mins.width + bilateral.getTrailing();
          if (actual > min)
            min = actual;
          actual = gap + prefs.width + bilateral.getTrailing();
          if (actual > pref)
            pref = actual;
        }
      }
    }
    int gap = layoutStyle.getContainerGap((JComponent) me, SwingConstants.EAST, parent);
    if (gap > min)
      min = gap;
    if (gap > pref)
      pref = gap;
    Spring spring = new Spring(min, pref);
View Full Code Here

  protected Alignment createHorizontalTrailing(Component me, Rectangle bounds, Container parent) {
    int min = Integer.MIN_VALUE;
    int pref = Integer.MIN_VALUE;
    int count = parent.getComponentCount();
    GroupLayout layout = (GroupLayout) parent.getLayout();
    LayoutStyle layoutStyle = LayoutStyle.getInstance();
    for (int i = 0; i < count; i++) {
      Component target = parent.getComponent(i);
      Constraints constraints = layout.getConstraints(target);
      Rectangle targetBounds = target.getBounds();
      if (constraints != null && isOverlap(bounds.y, bounds.height, targetBounds.y, targetBounds.height)) {
        Alignment horizontal = constraints.getHorizontal();
        Dimension prefs = target.getPreferredSize();
        Dimension mins = target.getMinimumSize();
        if (horizontal instanceof Leading) {
          int gap = layoutStyle.getPreferredGap((JComponent) target, (JComponent) me, ComponentPlacement.UNRELATED, SwingConstants.EAST, parent);
          Leading leading = (Leading) horizontal;
          int pref_size = leading.getSize() == Alignment.PREFERRED ? prefs.width : leading.getSize();
          int min_size = pref_size > mins.width ? mins.width : pref_size;
          int actual = gap + min_size + leading.getLeading();
          if (actual > min)
            min = actual;
          actual = gap + pref_size + leading.getLeading();
          if (actual > pref)
            pref = actual;
        } else if (horizontal instanceof Bilateral) {
          int gap = layoutStyle.getPreferredGap((JComponent) target, (JComponent) me, ComponentPlacement.RELATED, SwingConstants.EAST, parent);
          Bilateral bilateral = (Bilateral) horizontal;
          int actual = gap + mins.width + bilateral.getTrailing();
          if (actual > min)
            min = actual;
          actual = gap + prefs.width + bilateral.getTrailing();
          if (actual > pref)
            pref = actual;
        }
      }
    }
    int gap = layoutStyle.getContainerGap((JComponent) me, SwingConstants.WEST, parent);
    if (gap > min)
      min = gap;
    if (gap > pref)
      pref = gap;
    Spring spring = new Spring(min, pref);
View Full Code Here

  }
  public void initConainerLayout(Container container, IProgressMonitor monitor) {
    int count = container.getComponentCount();
    HashMap<JComponent, Constraints> comps = new HashMap<JComponent, Constraints>();
    ArrayList<JComponent> array = new ArrayList<JComponent>();
    LayoutStyle style = LayoutStyle.getInstance();
    for (int i = 0; i < count; i++) {
      JComponent widget = (JComponent) container.getComponent(i);
      int gap = style.getContainerGap(widget, SwingConstants.EAST, container);
      Rectangle bounds = widget.getBounds();
      Spring spring = new Spring(gap, gap);
      Leading horizontal = new Leading(bounds.x, bounds.width, spring);
      gap = style.getContainerGap(widget, SwingConstants.SOUTH, container);
      spring = new Spring(gap, gap);
      Leading vertical = new Leading(bounds.y, bounds.height, spring);
      Constraints constraints = new Constraints(horizontal, vertical);
      comps.put(widget, constraints);
      array.add(widget);
View Full Code Here

      }
    }
  }

  private boolean isTopRelatedTo(JComponent target, JComponent widget) {
    LayoutStyle style = LayoutStyle.getInstance();
    int nr = style.getPreferredGap(target, widget, ComponentPlacement.RELATED, SwingConstants.NORTH, container);
    int wr = style.getPreferredGap(target, widget, ComponentPlacement.RELATED, SwingConstants.WEST, container);
    int er = style.getPreferredGap(target, widget, ComponentPlacement.RELATED, SwingConstants.EAST, container);
    Rectangle tgtb = target.getBounds();
    Rectangle srcb = widget.getBounds();
    int tgtr = tgtb.y + tgtb.height;
    int srcy = srcb.y;
    if (srcy > tgtr) {
View Full Code Here

      }
    }
  }

  private boolean isBottomRelatedTo(JComponent target, JComponent widget) {
    LayoutStyle style = LayoutStyle.getInstance();
    int sr = style.getPreferredGap(target, widget, ComponentPlacement.RELATED, SwingConstants.SOUTH, container);
    int wr = style.getPreferredGap(target, widget, ComponentPlacement.RELATED, SwingConstants.WEST, container);
    int er = style.getPreferredGap(target, widget, ComponentPlacement.RELATED, SwingConstants.EAST, container);
    Rectangle tgtb = target.getBounds();
    Rectangle srcb = widget.getBounds();
    int tgty = tgtb.y;
    int srcr = srcb.y + srcb.height;
    if (tgty > srcr) {
View Full Code Here

      }
    }
  }

  private boolean isLeftRelatedTo(JComponent target, JComponent widget) {
    LayoutStyle style = LayoutStyle.getInstance();
    int wr = style.getPreferredGap(target, widget, ComponentPlacement.RELATED, SwingConstants.WEST, container);
    int nr = style.getPreferredGap(target, widget, ComponentPlacement.RELATED, SwingConstants.NORTH, container);
    int sr = style.getPreferredGap(target, widget, ComponentPlacement.RELATED, SwingConstants.SOUTH, container);
    Rectangle tgtb = target.getBounds();
    Rectangle srcb = widget.getBounds();
    int tgtr = tgtb.x + tgtb.width;
    int srcx = srcb.x;
    if (srcx > tgtr) {
View Full Code Here

TOP

Related Classes of org.dyno.visual.swing.layouts.LayoutStyle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.