Package net.helipilot50.stocktrade.displayproject

Examples of net.helipilot50.stocktrade.displayproject.ArrayColumn


  public void addColumn(String header, int width, TableCellRenderer renderer, TableCellEditor editor, boolean editable)
    {
        logger.debug("Add Column [" + header + "]");
        if (renderer == null && editor == null)
        {
            getColumnModel().addColumn(new ArrayColumn(header, columnCount, width, editable));
        }
        else if (renderer != null && editor == null)
        {
            getColumnModel().addColumn(new ArrayColumn(header, columnCount, width, renderer, editable));
        }
        else
        {
            getColumnModel().addColumn(new ArrayColumn(header, columnCount, width, renderer, editor, editable));
        }
        getColumnModel().getColumn(columnCount).setHeaderValue(header);
        columnCount++;
    }
View Full Code Here


          //                 
          TextGraphic label = new TextGraphic();
          label.setStandardJavaSizing(true);
          label.setText(value.toString());

          ArrayColumn ac = (ArrayColumn)ArrayField.this.getColumnModel().getColumn(column);
          label.setOpaque(true);
          if (ac.getHeaderFont() != null) label.setFont(ac.getHeaderFont());
          if (ac.getHeaderForeground() != null) label.setForeground(ac.getHeaderForeground());
          label.setHorizontalAlignment(ac.getHeaderHorizontalAlignment());
          label.setVerticalAlignment(ac.getHeaderVerticalAlignment());

          // CraigM:31/07/2008 - Use the defined header background if one exists
          if (ArrayField.this.headerBackground != null) {
            label.setBackground(ArrayField.this.headerBackground);
          }
          else {
            label.setBackground(header.getBackground());
          }

          // Put a margin around the labels.  CraigM: 07/08/2008.
          if (ArrayField.this.getColumnCount() == 1) {
            label.setBorder(ArrayField.headerRendererBorderOneCol);
          }
          else if (column == 0) {
            label.setBorder(ArrayField.headerRendererBorderLeft);
          }
          else if (column == ArrayField.this.getColumnCount()-1) {
            label.setBorder(ArrayField.headerRendererBorderRight);
          }
          else {
            label.setBorder(ArrayField.headerRendererBorderMiddle); // Put a margin around the labels
          }

          // CraigM: 15/07/2008 - If we are html formatted, we need to get Java to realise the label and calculate its actual size
          if (label.getText().startsWith("<html>")) {
            // TF:01/11/2008:Changed this expensive way of getting the size of a label with a much cheaper one.
            label.setPreferredSize(null);
            label.setMinimumSize(null);
            // TF:28/08/2009:We must validate the label, or we get the wrong size
            label.validate();
            Dimension d = label.getMinimumSize();
            View v = (View) label.getClientProperty(BasicHTML.propertyKey);
            if (v != null) {
              d.width = (int)v.getPreferredSpan(View.X_AXIS);
            }
            label.setPreferredSize(d);
            label.setMinimumSize(d);
            /*
                      label.setPreferredSize(null);
                      label.setMinimumSize(null);
                    final JFrame f = new JFrame();
                    f.setUndecorated(true);
                    f.getContentPane().add(label);
                    f.pack();
                    Dimension dim = label.getSize();
                    label.setPreferredSize(dim);
                    label.setMinimumSize(dim);
                    f.getContentPane().remove(label);

                    // Not sure why I can't just call f.dispose() directly, but for some reason, it deadlocks the EDT.
                    SwingUtilities.invokeLater(new Runnable() {
                      public void run() {
                        f.dispose();
                      }
                    });
             */
          }

          if (ac.getSizePolicy() == Constants.FP_FIXED) {
            Dimension size = label.getPreferredSize();
            size.width = ac.getWidth();
            label.setMinimumSize(size);
          }

          // COLET 13/01/2009 : Add support for rendering the label as disabled based on a hint from the array column.
          label.setEnabled(ac.isHeaderEnabled());
          return label;
        }
        else {
          return new JLabel("Column: "+column); // For visual editors.  CraigM 20/02/2008
        }
View Full Code Here

  public JComponent getColumnTemplate(String pCol) {
    Enumeration<TableColumn> cols = this.getColumnModel().getColumns();

    while (cols.hasMoreElements()) {
      ArrayColumn aCol = (ArrayColumn)cols.nextElement();

      if (aCol.getName().equals(pCol)) {
        return this.getColumnTemplate(aCol);
      }
    }
    return null;
  }
View Full Code Here

  }

  public boolean isCellEditable(int row, int column) {
    if (isEnabled()){
      // TF:10/02/2009:Changed this to cater for the stateColourForRow interface
      ArrayColumn ac = (ArrayColumn) getColumnModel().getColumn(column);
      if (ac.getStateColour() != null) {
        return ac.getStateColour().isEnabled(row);
      }
      ArrayFieldModel alm = (ArrayFieldModel)getModel();
      return alm.isCellEditable(row, column);
    }
    else
View Full Code Here

      ArrayFieldModel model = (ArrayFieldModel)getModel();
      Stroke defaultStroke = ((Graphics2D)g).getStroke();
      for (int row = rowCount; row <= currentHeightOfAllRows/rowHeight; row++) {
        int xPos = 0; // PM this needs to be zero because the line does not repaint correctly
        for (int col = 0; col < colModel.getColumnCount(); col++) {
          ArrayColumn column = (ArrayColumn)this.getColumnModel().getColumn(col);
          Color backgroundColour = this.getBackground();

          // Rectangle place holders
          g.setColor(backgroundColour);
          g.fillRect(xPos, row*rowHeight, column.getWidth(), rowHeight);

          // Details in rectangle place holders
          if (this.paintEmptyRowRectangles && rowHeight > inset*2 && column.getWidth() > inset*2) {

            // If we can append a row, we are on the last row, and this column is editable
            if (this.isAllowsAppendAndEditable() && row == rowCount && model.isColumnEditable(col)) {
              TableCellRenderer renderer = ((ArrayFieldCellRenderer)column.getCellRenderer()).getRenderer();

              // The renderer supports painting in an empty row.  CraigM:20/01/2009.
              if (renderer instanceof ArrayFieldEmptyCellRenderer) {
                // Paint an editable row (not faded)
                // TF:27/11/2009:Changed this to pass in the width, which allows us to draw the proper image when the column is resized.
                BufferedImage img = ((ArrayFieldEmptyCellRenderer)renderer).getImage(column.getWidth());
                g.drawImage(img, xPos + ((column.getWidth() - img.getWidth()) / 2), (row*rowHeight) + ((rowHeight - img.getHeight()) / 2), null);
              }

              // Draw a filled white rectangle
              else {
                Color emptyCellColor = backgroundColour.equals(Color.gray) ? Color.lightGray : Color.gray;
                g.setColor(emptyCellColor);
                g.drawRect(xPos+inset, (row*rowHeight)+inset, column.getWidth()-(inset*2), rowHeight-(inset*2));
              }
            }
            else {
              TableCellRenderer renderer = ((ArrayFieldCellRenderer)column.getCellRenderer()).getRenderer();

              // The renderer supports painting in an empty row.  CraigM:20/01/2009.
              if (renderer instanceof ArrayFieldEmptyCellRenderer) {
                // These are non editable rows, so fade them out a little
                ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
                BufferedImage img = ((ArrayFieldEmptyCellRenderer)renderer).getImage(column.getWidth());
                g.drawImage(img, xPos + ((column.getWidth() - img.getWidth()) / 2), (row*rowHeight) + ((rowHeight - img.getHeight()) / 2), null);
                ((Graphics2D)g).setComposite(AlphaComposite.Src);
              }
              else {
                Color emptyCellColor = backgroundColour.equals(Color.lightGray) ? Color.gray : Color.lightGray;
                g.setColor(emptyCellColor);
                ((Graphics2D)g).setStroke(dashed);
                g.drawRect(xPos+inset, (row*rowHeight)+inset, column.getWidth()-(inset*2), rowHeight-(inset*2));
              }
            }
          }
          // --- End ---
          xPos += column.getWidth();
        }
      }
      ((Graphics2D)g).setStroke(defaultStroke);
    }
  }
View Full Code Here

          else if (hitColumnIndex != -1 && this.isAllowsAppendAndEditable()) {
              int emptyRowStart = getRowHeight() * getRowCount();
              int emptyRowEnd = getRowHeight() * (getRowCount()+1);
             
              if (event.getY() > emptyRowStart && event.getY() < emptyRowEnd) {
                  ArrayColumn column = (ArrayColumn)this.getColumnModel().getColumn(hitColumnIndex);
                  component = column.getComponent();
              }
          }

      // Now have to see if the component is a JComponent before
      // getting the tip
View Full Code Here

      TextData statusTextValue = null;

      int columnAtPoint = columnAtPoint(e.getPoint());
      TableColumn column = getColumnModel().getColumn(columnAtPoint);
      if (column instanceof ArrayColumn) {
        ArrayColumn arrayColumn = (ArrayColumn) column;
        TableCellRenderer renderer = arrayColumn.getRenderer();
        if (renderer instanceof FormattedCellRenderer) {
          FormattedCellRenderer formatedRenderer = (FormattedCellRenderer) renderer;
          statusTextValue = (TextData) formatedRenderer.getDataFieldOriginalComponent().getClientProperty(StatusText.cSTATUS_TEXT);
        } else if (renderer instanceof ComboBoxCellRenderer) {
          statusTextValue = (TextData) ((ComboBoxCellRenderer)renderer).getComboBox().getClientProperty(StatusText.cSTATUS_TEXT);
View Full Code Here

         */
        //  Some test code to see if code below could be simplified
        if (this.getSorter().isSorting())  {
            int column = this.getSorter().getSortColumn();
            ArrayColumnModel columnModel = this.getColumnModel();
            ArrayColumn arrayColumn = columnModel.getRealColumn(column);
            TextData name = new TextData();
            name.setValue(arrayColumn.getName());
            if (name.moveToString("Item")) {
                name = name.copyRange(name.getOffset());
            }
            boolean ascending = (this.getSorter().getSortDirection() == TableSorter.ASCENDING);

View Full Code Here

        if (acm.getRealColumnCount() > 0) {
            columns = new Array_Of_OutlineColumnDesc<OutlineColumnDesc>();
        }
        */
        for (int i = 0; i < acm.getRealColumnCount(); i++){
            ArrayColumn col = (ArrayColumn)acm.getRealColumn(i);
            columns.add(this.getOutlineColumn(col, false));
        }
        return columns;
    }
View Full Code Here

              // TF:19/3/08: Added in a factor to make the columns approximately as wide as they are in Forte.
                colWidth = (int)(UIutils.colsToPixels(col.getMaxCharacters(), this) * UIutils.FORTE_COLUMNS_SCALING_FACTOR);
            }
            AlignedCellRenderer renderer = new AlignedCellRenderer(alignment, col.getName().toString());
            renderer.setInsets(0, 2, 0, 2);
            ArrayColumn ac = new ArrayColumn(col.getName().toString(),
                    colNum,
                    colWidth,
                    renderer,
                    false,
                    new Integer(col.getTitleMsgNum()));
           
            // CraigM:18/07/2008 - We need to set the size policy as it is used in ArrayFieldModel.resizeColumnIfNecessary()
            ac.setSizePolicy(col.getSizePolicy());
           
            // TF:19/06/2008:In Forte, the user could always adjust the widths of the columns in a list view. If we use
            // setMinWidth (as the ArrayColumn constructor does) then the user cannot reduce the columns smaller than
            // their initial size. Hence we use setMinWidth(0) and setPreferredWith. This is done here rather than in
            // the array column constructor as this rule applies only for list views, not array fields.
            ac.setMinWidth(0);
            ac.setPreferredWidth(colWidth);
           
            col.setArrayColumn(ac);
            cm.addColumn(ac, col.getTitle().toString(), col.getState() != Constants.FS_INVISIBLE);

            propNames[colNum] = col.getName().toString();
View Full Code Here

TOP

Related Classes of net.helipilot50.stocktrade.displayproject.ArrayColumn

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.