示例#1
0
  private void createBorderSelectionPanel() {
    Map map = getAttributeMap();

    borderSelectionPanel = new TBorderSelectionPanel();

    borderSelectionPanel.setBorderColor(TBoardConstants.getBorderColor(map));
    borderSelectionPanel.setBorderSize(Math.max(1, Math.round(TBoardConstants.getLineWidth(map))));
  }
示例#2
0
  private void createBackgroundSelectionPanel() {
    Map map = getAttributeMap();

    backgroundSelectionPanel = new TBackgroundSelectionPanel();

    backgroundSelectionPanel.setBackgroundColor(TBoardConstants.getBackground(map));
    backgroundSelectionPanel.setGradientColor(TBoardConstants.getGradientColor(map));
  }
示例#3
0
  private void createTextAlignSelector() {
    Map map = getAttributeMap();

    textAlignSelectorPanel = new TTextAlignSelectorPanel();

    textAlignSelectorPanel.setHorizontalAlignment(TBoardConstants.getHorizontalAlignment(map));
    textAlignSelectorPanel.setVerticalAlignment(TBoardConstants.getVerticalAlignment(map));
  }
示例#4
0
  private void createFontModel() {
    Map map = getAttributeMap();

    fontModel =
        new TFontModelChooser(
            TBoardConstants.getFont(map).getName(),
            TBoardConstants.getForeground(map),
            TBoardConstants.getFont(map).getSize(),
            TBoardConstants.getFont(map).getStyle());
  }
示例#5
0
  private void createIdField() {
    idFieldPanel = new JPanel();

    idFieldPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    idFieldPanel.add(new JLabel(TLanguage.getString("TTextAreaDialog.ID")));

    idTextField = new TIdTextField();
    idFieldPanel.add(idTextField);

    idTextField.setText(TBoardConstants.getId(getAttributeMap()));
  }
示例#6
0
  private void createTextField() {
    Map map = getAttributeMap();

    textFieldPanel = new JPanel();

    textFieldPanel.setBorder(
        new TitledBorder(
            BorderFactory.createEtchedBorder(Color.WHITE, new Color(165, 163, 151)),
            TLanguage.getString("TTextAreaDialog.TEXT")));

    textField = new TTextField(TBoardConstants.getText(map));
    textField.setColumns(30);

    textFieldPanel.add(textField);
  }
示例#7
0
  /* (non-Javadoc)
   * @see tico.editor.dialogs.TComponentDialog#newComponentsAttributeMap()
   */
  protected Map newComponentsAttributeMap() {
    Map nested = new Hashtable();
    Map attributeMap = new Hashtable();
    Vector removalAttributes = new Vector();

    TBoardConstants.setText(attributeMap, textField.getText());

    TBoardConstants.setForeground(attributeMap, fontModel.getFontColor());
    TBoardConstants.setFont(
        attributeMap,
        new Font(fontModel.getFontFace(), fontModel.getFontStyle(), fontModel.getFontSize()));

    TBoardConstants.setHorizontalAlignment(
        attributeMap, textAlignSelectorPanel.getHorizontalAlignment());
    TBoardConstants.setVerticalAlignment(
        attributeMap, textAlignSelectorPanel.getVerticalAlignment());

    Color color = borderSelectionPanel.getBorderColor();
    if (color != null) TBoardConstants.setBorderColor(attributeMap, color);
    else removalAttributes.add(TBoardConstants.BORDERCOLOR);

    TBoardConstants.setLineWidth(attributeMap, borderSelectionPanel.getBorderSize());

    Color background = backgroundSelectionPanel.getBackgroundColor();
    if (background != null) TBoardConstants.setBackground(attributeMap, background);
    else removalAttributes.add(TBoardConstants.BACKGROUND);

    Color gradient = backgroundSelectionPanel.getGradientColor();
    if (gradient != null) TBoardConstants.setGradientColor(attributeMap, gradient);
    else removalAttributes.add(TBoardConstants.GRADIENTCOLOR);

    TBoardConstants.setRemoveAttributes(attributeMap, removalAttributes.toArray());

    TBoardConstants.setId(attributeMap, idTextField.getText());

    nested.put(getComponent(), attributeMap);

    return nested;
  }
  /* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    Map nested = new Hashtable();
    Map attributeMap;

    int selectedCellsCount;

    ArrayList unorderedCells, orderedCells;

    double verticalGapSize, lastCellPlace;

    TComponent currentCell;
    Rectangle2D currentBounds, newBounds;

    // Remove TGrids from the selected components
    Object[] selectedCells = getEditor().getCurrentBoard().getSelectionCells();
    for (int i = 0; i < selectedCells.length; i++)
      if (selectedCells[i] instanceof TGrid)
        getEditor().getCurrentBoard().removeSelectionCell(selectedCells[i]);

    selectedCellsCount = getEditor().getCurrentBoard().getSelectionCount();

    // I don't have to modify any component
    if (selectedCellsCount < 3) return;

    // Order using its X position
    unorderedCells = new ArrayList();
    orderedCells = new ArrayList();
    for (int i = 0; i < selectedCellsCount; i++)
      unorderedCells.add(getEditor().getCurrentBoard().getSelectionCells()[i]);

    for (int i = 0; i < selectedCellsCount; i++) {
      TComponent minCell = (TComponent) unorderedCells.get(0);
      currentBounds = TBoardConstants.getBounds(minCell.getAttributes());
      double minPosition = currentBounds.getY();

      for (int j = 1; j < unorderedCells.size(); j++) {
        currentCell = (TComponent) unorderedCells.get(j);
        currentBounds = TBoardConstants.getBounds(currentCell.getAttributes());
        if (currentBounds.getY() < minPosition) {
          minPosition = currentBounds.getY();
          minCell = currentCell;
        }
      }

      orderedCells.add(minCell);
      unorderedCells.remove(minCell);
    }

    // Get the horizontal gap size
    verticalGapSize =
        TBoardConstants.getBounds(
                    ((TComponent) orderedCells.get(orderedCells.size() - 1)).getAttributes())
                .getY()
            - TBoardConstants.getBounds(((TComponent) orderedCells.get(0)).getAttributes()).getY();
    for (int i = 0; i < selectedCellsCount - 1; i++)
      verticalGapSize -=
          TBoardConstants.getBounds(((TComponent) orderedCells.get(i)).getAttributes()).getHeight();
    verticalGapSize = verticalGapSize / (float) (orderedCells.size() - 1);

    // Replace all the components
    lastCellPlace =
        TBoardConstants.getBounds(((TComponent) orderedCells.get(0)).getAttributes()).getY()
            + TBoardConstants.getBounds(((TComponent) orderedCells.get(0)).getAttributes())
                .getHeight();

    for (int i = 1; i < selectedCellsCount - 1; i++) {
      attributeMap = new AttributeMap();

      currentCell = (TComponent) orderedCells.get(i);
      currentBounds = (Rectangle2D) TBoardConstants.getBounds(currentCell.getAttributes());
      newBounds =
          new Rectangle2D.Double(
              currentBounds.getX(),
              lastCellPlace + verticalGapSize,
              currentBounds.getWidth(),
              currentBounds.getHeight());

      TBoardConstants.setBounds(attributeMap, newBounds);
      nested.put(currentCell, attributeMap);

      lastCellPlace += verticalGapSize + currentBounds.getHeight();
    }

    getEditor().getCurrentBoard().getGraphLayoutCache().edit(nested, null, null, null);
  }