Package org.dyno.visual.swing.layouts

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


    return last_constraints;
  }

  @Override
  public void addChild(Component widget) {
    Constraints cons = new Constraints(new Leading(10, 10, 10), new Leading(10, 10, 10));
    container.add(widget, cons);
  }
View Full Code Here


      int count = adapter.getChildCount();
      for (int i = 0; i < count; i++) {
        Component child = adapter.getChild(i);
        WidgetAdapter childAdapter = WidgetAdapter.getWidgetAdapter(child);
        if (childAdapter.isSelected()) {
          Constraints constraints = layout.getConstraints(child);
          Alignment horizontal = constraints.getHorizontal();
          int y = child.getY() + child.getHeight() / 2;
          int x = 0;
          if (horizontal instanceof Leading) {
            x = ((Leading) horizontal).getLeading();
            g2d.drawLine(insets.left, y, insets.left + x, y);
            Polygon polygon = new Polygon();
            polygon.addPoint(insets.left, y - BOX + 1);
            polygon.addPoint(insets.left, y + BOX);
            polygon.addPoint(insets.left + BOX, y);
            g2d.fillPolygon(polygon);
          } else if (horizontal instanceof Trailing) {
            x = child.getX() + child.getWidth();
            g2d.drawLine(width - insets.right, y, x, y);
            Polygon polygon = new Polygon();
            polygon.addPoint(width - insets.right, y - BOX);
            polygon.addPoint(width - insets.right, y + BOX - 1);
            polygon.addPoint(width - BOX - insets.right, y);
            g2d.fillPolygon(polygon);
          } else if (horizontal instanceof Bilateral) {
            x = ((Bilateral) horizontal).getLeading();
            g2d.drawLine(insets.left, y, insets.left + x, y);
            Polygon polygon = new Polygon();
            polygon.addPoint(insets.left, y - BOX + 1);
            polygon.addPoint(insets.left, y + BOX);
            polygon.addPoint(insets.left + BOX, y);
            g2d.fillPolygon(polygon);
            x = child.getX() + child.getWidth();
            g2d.drawLine(width - insets.right, y, x, y);
            polygon = new Polygon();
            polygon.addPoint(width - insets.right, y - BOX);
            polygon.addPoint(width - insets.right, y + BOX - 1);
            polygon.addPoint(width - BOX - insets.right, y);
            g2d.fillPolygon(polygon);
          }
          Alignment vertical = constraints.getVertical();
          x = child.getX() + child.getWidth() / 2;
          if (vertical instanceof Leading) {
            y = ((Leading) vertical).getLeading();
            g2d.drawLine(x, insets.top, x, insets.top + y);
            Polygon polygon = new Polygon();
View Full Code Here

      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);
    }
    container.removeAll();
    GroupLayout layout = new GroupLayout();
    container.setLayout(layout);
    for (JComponent widget : array) {
      Constraints constraints = comps.get(widget);
      container.add(widget, constraints);
    }
    container.doLayout();
    container.validate();
    JavaUtil.setupLayoutLib(monitor);
View Full Code Here

    CompositeAdapter parent = (CompositeAdapter) WidgetAdapter.getWidgetAdapter(container);
    int count = parent.getChildCount();
    for (int i = 0; i < count; i++) {
      JComponent child = (JComponent) parent.getChild(i);
      WidgetAdapter cAdapter = WidgetAdapter.getWidgetAdapter(child);
      Constraints childConstraints = layout.getConstraints(child);
      panel.add(cAdapter.cloneWidget(), childConstraints==null?null:childConstraints.clone());
    }
    return true;
  }
View Full Code Here

  }

  @Override
  public void adjustLayout(Component widget) {
    GroupLayout layout = (GroupLayout) container.getLayout();
    Constraints constraints = layout.getConstraints(widget);
    Alignment horizontal = constraints.getHorizontal();
    if (horizontal instanceof Leading) {
      Leading leading = (Leading) horizontal;
      if (leading.getSize() == Alignment.PREFERRED) {
        int now_width = widget.getWidth();
        int pref_width = widget.getPreferredSize().width;
        int delta_width = pref_width - now_width;
        if (delta_width != 0) {
          adjustHorizontalLeadingBy(widget, delta_width);
          container.doLayout();
          container.validate();
        }
      } else {
        int delta_width = leading.getSize() - widget.getWidth();
        if (delta_width != 0) {
          adjustHorizontalLeadingBy(widget, delta_width);
          container.doLayout();
          container.validate();
        }
      }
    } else if (horizontal instanceof Trailing) {
      Trailing trailing = (Trailing) horizontal;
      if (trailing.getSize() == Alignment.PREFERRED) {
        int now_width = widget.getWidth();
        int pref_width = widget.getPreferredSize().width;
        int delta_width = pref_width - now_width;
        if (delta_width != 0) {
          adjustHorizontalTrailingBy(widget, delta_width);
          container.doLayout();
          container.validate();
        }
      } else {
        int delta_width = trailing.getSize() - widget.getWidth();
        if (delta_width != 0) {
          adjustHorizontalTrailingBy(widget, delta_width);
          container.doLayout();
          container.validate();
        }
      }
    }

    Alignment vertical = constraints.getVertical();
    if (vertical instanceof Leading) {
      Leading leading = (Leading) vertical;
      if (leading.getSize() == Alignment.PREFERRED) {
        int now_height = widget.getHeight();
        int pref_height = widget.getPreferredSize().height;
View Full Code Here

    int count = containerAdapter.getChildCount();
    for (int i = 0; i < count; i++) {
      Component target = containerAdapter.getChild(i);
      if (target != widget) {
        if (isTopRelatedTo((JComponent) target, (JComponent) widget)) {
          Constraints constraints = layout.getConstraints(target);
          Alignment vertical = constraints.getHorizontal();
          if (vertical instanceof Trailing) {
            Trailing leading = (Trailing) vertical;
            leading.setTrailing(leading.getTrailing() + delta_height);
            adjustVerticalTrailingBy(target, delta_height);
          } else if (vertical instanceof Bilateral) {
View Full Code Here

    int count = containerAdapter.getChildCount();
    for (int i = 0; i < count; i++) {
      Component target = containerAdapter.getChild(i);
      if (target != widget) {
        if (isBottomRelatedTo((JComponent) target, (JComponent) widget)) {
          Constraints constraints = layout.getConstraints(target);
          Alignment vertical = constraints.getVertical();
          if (vertical instanceof Leading) {
            Leading leading = (Leading) vertical;
            leading.setLeading(leading.getLeading() + delta_height);
            adjustVerticalLeadingBy(target, delta_height);
          } else if (vertical instanceof Bilateral) {
View Full Code Here

    int count = containerAdapter.getChildCount();
    for (int i = 0; i < count; i++) {
      Component target = containerAdapter.getChild(i);
      if (target != widget) {
        if (isLeftRelatedTo((JComponent) target, (JComponent) widget)) {
          Constraints constraints = layout.getConstraints(target);
          Alignment horizontal = constraints.getHorizontal();
          if (horizontal instanceof Trailing) {
            Trailing leading = (Trailing) horizontal;
            leading.setTrailing(leading.getTrailing() + delta_width);
            adjustHorizontalTrailingBy(target, delta_width);
          } else if (horizontal instanceof Bilateral) {
View Full Code Here

    int count = containerAdapter.getChildCount();
    for (int i = 0; i < count; i++) {
      Component target = containerAdapter.getChild(i);
      if (target != widget) {
        if (isRightRelatedTo((JComponent) target, (JComponent) widget)) {
          Constraints constraints = layout.getConstraints(target);
          Alignment horizontal = constraints.getHorizontal();
          if (horizontal instanceof Leading) {
            Leading leading = (Leading) horizontal;
            leading.setLeading(leading.getLeading() + delta_width);
            adjustHorizontalLeadingBy(target, delta_width);
          } else if (horizontal instanceof Bilateral) {
View Full Code Here

  }

  @Override
  public Object getChildConstraints(Component child) {
    GroupLayout layout = (GroupLayout) container.getLayout();
    Constraints constraints = layout.getConstraints(child);
    return constraints;
  }
View Full Code Here

TOP

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

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.