Package edu.cmu.relativelayout

Examples of edu.cmu.relativelayout.Binding


    bf = new BindingFactory(10, 10, 10, 10, 10, 10);
    dim = Toolkit.getDefaultToolkit().getScreenSize();
  }

  public void initializeLayout() {
    Binding leftEdge = bf.leftEdge();
    Binding topEdge = bf.topEdge();
    Binding aboveInputField = bf.above(inputField);

    // PAINT CANVAS
    // paintCanvas properties
    paintCanvas.setBorder(BorderFactory.createLineBorder(new Color(161,
        112, 23), 3));
    paintCanvas.setSize(200, 500);
    paintCanvas.setBackground(new Color(204, 204, 204));
    // paintCanvas.setCursor(Cursor.getPredefinedCursor(Cursor.));

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image image = toolkit.getImage("images/Brush.png");
    Cursor c = toolkit.createCustomCursor(image,
        new Point(paintCanvas.getX(), paintCanvas.getY()), "img");
    paintCanvas.setCursor(c);

    paintCanvas.addMouseMotionListener(new MouseMotionListener() {

      @Override
      public void mouseMoved(MouseEvent arg0) {
      }

      @Override
      public void mouseDragged(MouseEvent e) {
        x2 = e.getX();
        y2 = e.getY();

        try {
          serverObj.setPoints(roomNo, x1, y1, x2, y2);
        } catch (RemoteException e1) {
          e1.printStackTrace();
        }

        x1 = e.getX();
        y1 = e.getY();
      }
    });

    paintCanvas.addMouseListener(new MouseListener() {

      @Override
      public void mouseReleased(MouseEvent e) {
      }

      @Override
      public void mousePressed(MouseEvent e) {
        x1 = e.getX();
        y1 = e.getY();
      }

      @Override
      public void mouseExited(MouseEvent e) {
      }

      @Override
      public void mouseEntered(MouseEvent e) {
      }

      @Override
      public void mouseClicked(MouseEvent e) {
      }
    });

    Binding leftOfUserList = bf.leftOf(userList);
    paintCanvasConstraints = new RelativeConstraints(leftEdge,
        leftOfUserList, topEdge, aboveInputField);

    // User List
    userList.setBackground(new Color(102, 255, 153));
    userList.setPreferredSize(new Dimension(200, userList.getHeight()));
    users.setEditable(false);
    Binding rightEdge = bf.rightEdge();
    userListConstraints = new RelativeConstraints(topEdge, rightEdge,
        aboveInputField);

    // Input Field
    inputField.setEnabled(true);
    inputField.setVisible(true);
    inputField.setPreferredSize(new Dimension(700, 30));
    Binding bottomEdge = bf.bottomEdge();
    Binding leftOfSendButton = bf.leftOf(sendButton);
    Binding aboveChatPane = bf.above(chatPane);
    inputFieldConstraints = new RelativeConstraints(leftEdge,
        aboveChatPane, leftOfSendButton);

    // Send Button
    sendButton.setEnabled(true);
    sendButton.addActionListener(this);
    sendButton.setPreferredSize(new Dimension(150, 30));
    Binding ver = bf.verticallyCenterAlignedWith(inputField);
    sendButtonConstrains = new RelativeConstraints(rightEdge, ver);
    chatPane.setBackground(new Color(255, 255, 153));
    chatPane.setPreferredSize(new Dimension(1000, 100));
    chatPaneConstraints = new RelativeConstraints(leftEdge, bottomEdge,
        rightEdge);
View Full Code Here


    Border b = BorderFactory.createBevelBorder(BevelBorder.RAISED);
    corner.setBorder(b);

    JButton button = new JButton("Hello");

    Binding twelvePixelsFromLeft = new Binding(Edge.LEFT, 12, Direction.RIGHT, Edge.LEFT, Binding.PARENT);
    Binding twelvePixelsFromTop = new Binding(Edge.TOP, 12, Direction.BELOW, Edge.TOP, Binding.PARENT);
    Binding verticallyCentered = new Binding(Edge.VERTICAL_CENTER, 0, Direction.ABOVE, Edge.VERTICAL_CENTER, corner);
    Binding horizontallyCenteredWithOffset =
        new Binding(Edge.HORIZONTAL_CENTER, (96 + 12) / 2, Direction.RIGHT, Edge.HORIZONTAL_CENTER,
                    Binding.PARENT);
    // RelativePosition twelvePixelsToTheRightOf = new
    // RelativePosition(RelativePosition.Edge.LEFT, 12,
    // RelativePosition.Direction.RIGHT, RelativePosition.Edge.RIGHT);
    // RelativePosition twelvePixelsFromRight = new
View Full Code Here

    JTextArea area = new JTextArea("Some text here.");
    area.setBorder(new BevelBorder(BevelBorder.LOWERED));
    JButton okButton = new JButton("OK");
    JButton cancelButton = new JButton("Cancel");

    Binding leftMarginTwelve = new Binding(Edge.LEFT, 12, Direction.RIGHT, Edge.LEFT, frame);
    Binding rightMarginTwelve = new Binding(Edge.RIGHT, 12, Direction.LEFT, Edge.RIGHT, frame);
    Binding topMarginTwelve = new Binding(Edge.TOP, 12, Direction.BELOW, Edge.TOP, frame);
    Binding bottomMarginTwelve = new Binding(Edge.BOTTOM, 12, Direction.ABOVE, Edge.BOTTOM, frame);
    Binding twelveToTheLeftOf = new Binding(Edge.RIGHT, 12, Direction.LEFT, Edge.LEFT, okButton);

    Binding twelveAbove = new Binding(Edge.BOTTOM, 12, Direction.ABOVE, Edge.TOP, okButton);
    Binding twelveBelow = new Binding(Edge.TOP, 12, Direction.BELOW, Edge.BOTTOM, label);

    RelativeConstraints labelConstraint = new RelativeConstraints();
    labelConstraint.addBindings(leftMarginTwelve, topMarginTwelve);

    RelativeConstraints okButtonConstraint = new RelativeConstraints();
View Full Code Here

    JButton two = new JButton("Two");
    JButton three = new JButton("Three");

    RelativePosition tenToTheRight = new RelativePosition(Edge.LEFT, 10, Direction.RIGHT, Edge.RIGHT);

    Binding wtf = new Binding(Edge.VERTICAL_CENTER, 12, Direction.LEFT, Edge.VERTICAL_CENTER, two);
    Binding moreWtf = new Binding(Edge.VERTICAL_CENTER, 12, Direction.LEFT, Edge.HORIZONTAL_CENTER, three);
    Binding stillMoreWtf = new Binding(Edge.TOP, 12, Direction.ABOVE, Edge.LEFT, one);

    System.out.println("Sane relation valid: " + tenToTheRight.isValid());
    System.out.println("RelativePosition 1 valid: " + wtf.isValid());
    System.out.println("RelativePosition 2 valid: " + moreWtf.isValid());
    System.out.println("RelativePosition 3 valid: " + stillMoreWtf.isValid());

    RelativeConstraints c1 = new RelativeConstraints();
    c1.addBinding(wtf);

    RelativeConstraints c2 = new RelativeConstraints();
    c2.addBinding(moreWtf);

    RelativeConstraints c3 = new RelativeConstraints();
    c3.addBinding(stillMoreWtf);

    c3.addBinding(new Binding(tenToTheRight, two));
    c2.addBinding(new Binding(tenToTheRight, one));

    frame.add(one, c1);
    frame.add(two, c2);
    frame.add(three, c3);
View Full Code Here

    JButton one = new JButton("One");
    JButton two = new JButton("Two");
    JButton three = new JButton("Three");

    RelativeConstraints oneConstraints =
        new RelativeConstraints(new Binding(Edge.LEFT, 12, Direction.RIGHT, Edge.LEFT, frame),
                                new Binding(Edge.TOP, 12, Direction.BELOW, Edge.TOP, frame));
    RelativeConstraints twoConstraints =
        new RelativeConstraints(new Binding(Edge.LEFT, 12, Direction.RIGHT, Edge.RIGHT, one),
                                new Binding(Edge.TOP, 12, Direction.BELOW, Edge.TOP, frame));
    RelativeConstraints threeConstraints =
        new RelativeConstraints(new Binding(Edge.LEFT, 12, Direction.RIGHT, Edge.RIGHT, two),
                                new Binding(Edge.TOP, 12, Direction.BELOW, Edge.TOP, frame));

    frame.add(one, oneConstraints);
    frame.add(two, twoConstraints);
    frame.add(three, threeConstraints);
    frame.pack();
View Full Code Here

    JButton four = new JButton("Four");
    JButton five = new JButton("Five");

    final int WINDOW_PADDING = 12;

    frame.add(one, new RelativeConstraints(new Binding(Edge.LEFT, WINDOW_PADDING, Direction.RIGHT, Edge.LEFT, frame),
                                           new Binding(Edge.TOP, WINDOW_PADDING, Direction.BELOW, Edge.TOP, frame)));
    frame.add(two, new RelativeConstraints(new Binding(Edge.RIGHT, WINDOW_PADDING, Direction.LEFT, Edge.RIGHT, frame),
                                           new Binding(Edge.TOP, WINDOW_PADDING, Direction.BELOW, Edge.TOP, frame)));
    frame.add(three, new RelativeConstraints(new Binding(Edge.LEFT, WINDOW_PADDING, Direction.RIGHT, Edge.LEFT, frame),
                                             new Binding(Edge.BOTTOM, WINDOW_PADDING, Direction.ABOVE, Edge.BOTTOM,
                                                         frame)));
    frame.add(four, new RelativeConstraints(new Binding(Edge.RIGHT, WINDOW_PADDING, Direction.LEFT, Edge.RIGHT, frame),
                                            new Binding(Edge.BOTTOM, WINDOW_PADDING, Direction.ABOVE, Edge.BOTTOM,
                                                        frame)));
    frame.add(five, new RelativeConstraints(new Binding(Edge.TOP, 0, Direction.BELOW, Edge.BOTTOM, one),
                                            new Binding(Edge.LEFT, WINDOW_PADDING, Direction.RIGHT, Edge.LEFT, frame)));

    frame.pack();
    frame.setVisible(true);
  }
View Full Code Here

    toolbar.add(new JLabel("Forward"));

    JPanel statusBar = new JPanel(new BorderLayout());
    statusBar.add(new JLabel("Unread: 0   Total: 4"), BorderLayout.EAST);

    Binding leftEdge = new Binding(Edge.LEFT, 0, Direction.RIGHT, Edge.LEFT, frame);
    Binding rightEdge = new Binding(Edge.RIGHT, 0, Direction.LEFT, Edge.RIGHT, frame);
    Binding topEdge = new Binding(Edge.TOP, 0, Direction.BELOW, Edge.TOP, frame);
    Binding bottomEdge = new Binding(Edge.BOTTOM, 0, Direction.ABOVE, Edge.BOTTOM, frame);

    RelativePosition justBelow = new RelativePosition(Edge.TOP, 0, Direction.BELOW, Edge.BOTTOM);
    RelativePosition justAbove = new RelativePosition(Edge.BOTTOM, 0, Direction.ABOVE, Edge.TOP);
    RelativePosition eightBelow = new RelativePosition(Edge.TOP, 8, Direction.BELOW, Edge.BOTTOM);
    RelativePosition eightRightOf = new RelativePosition(Edge.LEFT, 8, Direction.RIGHT, Edge.RIGHT);

    RelativeConstraints toolbarConstraints = new RelativeConstraints();
    toolbarConstraints
                      .addBindings(
                                   new Binding(Edge.HORIZONTAL_CENTER, 0, Direction.LEFT, Edge.HORIZONTAL_CENTER, frame),
                                   topEdge);
    frame.add(toolbar, toolbarConstraints);

    RelativeConstraints folderViewConstraints = new RelativeConstraints();
    folderViewConstraints.addBindings(leftEdge, new Binding(justBelow, toolbar), new Binding(justAbove, statusBar));
    frame.add(folderView, folderViewConstraints);

    RelativeConstraints mailListConstraints = new RelativeConstraints();
    mailListConstraints.addBindings(new Binding(justBelow, toolbar), new Binding(eightRightOf, folderView), rightEdge);
    frame.add(mailList, mailListConstraints);

    RelativeConstraints mailAreaConstraints = new RelativeConstraints();
    mailAreaConstraints.addBindings(new Binding(eightBelow, mailList), new Binding(eightRightOf, folderView),
                                    new Binding(justAbove, statusBar), rightEdge);
    frame.add(mailArea, mailAreaConstraints);

    RelativeConstraints statusBarConstraints = new RelativeConstraints();
    statusBarConstraints.addBindings(bottomEdge, leftEdge, new Binding(Edge.RIGHT, 20, Direction.LEFT, Edge.RIGHT,
                                                                       frame));
    frame.add(statusBar, statusBarConstraints);

    frame.setSize(800, 400);
    frame.setVisible(true);
View Full Code Here

    JTextArea area = new JTextArea("Some text here.");
    JLabel okLabel = new JLabel("OK");
    JButton addButton = new JButton("Add");
    JButton editButton = new JButton("Edit");

    Binding toTheRightInside = new Binding(Edge.LEFT, 12, Direction.RIGHT, Edge.LEFT, frame);

    Binding belowInside = new Binding(Edge.TOP, 12, Direction.BELOW, Edge.TOP, frame);

    Binding aboveInside = new Binding(Edge.BOTTOM, 12, Direction.ABOVE, Edge.BOTTOM, frame);

    Binding toTheLeftInside = new Binding(Edge.RIGHT, 15, Direction.LEFT, Edge.RIGHT, frame);

    Binding toTheLeftOutside = new Binding(Edge.RIGHT, 7, Direction.LEFT, Edge.LEFT, addButton);

    Binding belowOutside = new Binding(Edge.TOP, 3, Direction.BELOW, Edge.BOTTOM, addButton);

    Binding alignBottoms = new Binding(Edge.BOTTOM, 8, Direction.ABOVE, Edge.BOTTOM, frame);

    RelativeConstraints areaConstraint = new RelativeConstraints();
    areaConstraint.addBinding(toTheRightInside);
    areaConstraint.addBinding(belowInside);
    areaConstraint.addBinding(aboveInside);
View Full Code Here

TOP

Related Classes of edu.cmu.relativelayout.Binding

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.