Search in sources :

Example 11 with MatteBorder

use of javax.swing.border.MatteBorder in project adempiere by adempiere.

the class VHeaderRenderer method getTableCellRendererComponent.

/**
	 *	Get TableCell RendererComponent
	 *  @param table
	 *  @param value
	 *  @param isSelected
	 *  @param hasFocus
	 *  @param row
	 *  @param column
	 *  @return Button
	 */
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    //  indicator for invisible column
    Icon icon = null;
    m_table = table;
    m_column = column;
    if (table instanceof CTable) {
        CTable cTable = (CTable) table;
        if (cTable.getSortColumn() == table.convertColumnIndexToModel(column)) {
            icon = cTable.isSortAscending() ? Env.getImageIcon2("uparrow") : Env.getImageIcon2("downarrow");
        }
    }
    /**
		 * If VHeaderRenderer is just created with display type as argument
		 */
    if (m_label == null && m_button == null && m_check == null) {
        TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer();
        Component headerComponent = headerRenderer == null ? null : headerRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        if (value == null)
            headerComponent.setPreferredSize(new Dimension(0, 0));
        if (headerComponent instanceof JLabel) {
            ((JLabel) headerComponent).setIcon(icon);
            ((JLabel) headerComponent).setHorizontalTextPosition(SwingConstants.LEADING);
        }
        return headerComponent;
    }
    /**
		 * If VHeaderRenderer has been created with GridField as argument
		 */
    if (m_button == null && m_check == null) {
        m_label.setHorizontalAlignment(m_alignment);
        if (value == null)
            m_label.setPreferredSize(new Dimension(0, 0));
        else {
            m_label.setText(value.toString());
            if (prefWidth != null && prefWidth > 0) {
                m_label.setPreferredSize(new Dimension(prefWidth, m_label.getHeight()));
                m_label.setToolTipText(value.toString());
            }
        }
        m_label.setIcon(icon);
        m_label.setHorizontalTextPosition(SwingConstants.LEADING);
        return m_label;
    }
    /**
		 * VHeaderRenderer has been created with multi-selection true
		 */
    if (m_button == null) {
        if (table != null) {
            JTableHeader header = table.getTableHeader();
            if (header != null) {
                m_check.setForeground(header.getForeground());
                m_check.setBackground(header.getBackground());
                m_check.setBorder(new MatteBorder(0, 0, 1, 1, AdempierePLAF.getSecondary1()));
                m_check.setFont(header.getFont());
                m_check.setBorderPainted(true);
                m_check.setEnabled(true);
                header.addMouseListener(this);
            }
        }
        return m_check;
    } else {
        /**
			 * VHeaderRenderer has been created with no argument
			 */
        if (value == null) {
            m_button.setPreferredSize(new Dimension(0, 0));
            return m_button;
        }
        m_button.setText(value.toString());
        m_button.setIcon(icon);
        m_button.setHorizontalTextPosition(SwingConstants.LEADING);
        return m_button;
    }
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) MatteBorder(javax.swing.border.MatteBorder) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) CTable(org.compiere.swing.CTable) Icon(javax.swing.Icon) Dimension(java.awt.Dimension) Component(java.awt.Component)

Example 12 with MatteBorder

use of javax.swing.border.MatteBorder in project vcell by virtualcell.

the class DefaultScrollTableCellRenderer method issueRenderer.

public static void issueRenderer(JLabel renderer, String defaultToolTipText, JTable table, int row, int column, SortTableModel tableModel) {
    List<Issue> issueListError = tableModel.getIssues(row, column, Issue.Severity.ERROR);
    List<Issue> issueListWarning = tableModel.getIssues(row, column, Issue.Severity.WARNING);
    Icon icon = null;
    Point mousePosition = table.getMousePosition();
    // hue, saturation, brightness
    Color red = Color.getHSBColor(0f, 0.4f, 1.0f);
    if (issueListError.size() > 0) {
        if (column == 0) {
            icon = VCellIcons.issueErrorIcon;
            if (mousePosition != null && mousePosition.getX() > LEFT_ICON_MARGIN && mousePosition.getX() <= (icon.getIconWidth() + LEFT_ICON_MARGIN)) {
                String tt = Issue.getHtmlIssueMessage(issueListError);
                renderer.setToolTipText(tt);
            } else {
                renderer.setToolTipText(defaultToolTipText);
            }
            // Color.red
            renderer.setBorder(new MatteBorder(1, 1, 1, 0, red));
        } else if (column == table.getColumnCount() - 1) {
            renderer.setBorder(new MatteBorder(1, 0, 1, 1, red));
        } else {
            renderer.setBorder(new MatteBorder(1, 0, 1, 0, red));
        }
    } else if (issueListWarning.size() > 0) {
        if (column == 0) {
            icon = VCellIcons.issueWarningIcon;
            if (mousePosition != null && mousePosition.getX() > LEFT_ICON_MARGIN && mousePosition.getX() <= (icon.getIconWidth() + LEFT_ICON_MARGIN)) {
                renderer.setToolTipText(Issue.getHtmlIssueMessage(issueListWarning));
            } else {
                renderer.setToolTipText(defaultToolTipText);
            }
            renderer.setBorder(new MatteBorder(1, 1, 1, 0, Color.orange));
        } else if (column == table.getColumnCount() - 1) {
            renderer.setBorder(new MatteBorder(1, 0, 1, 1, Color.orange));
        } else {
            renderer.setBorder(new MatteBorder(1, 0, 1, 0, Color.orange));
        }
    } else {
        if (column == 0) {
            icon = VCellIcons.issueGoodIcon;
            // no tooltip for column 0 when we have no issues on that line
            renderer.setToolTipText(null);
        }
        if (column != 0 && defaultToolTipText != null && !defaultToolTipText.isEmpty()) {
            renderer.setToolTipText(defaultToolTipText);
        } else {
            renderer.setToolTipText(null);
        }
        renderer.setBorder(DEFAULT_GAP);
    }
    if (column == 0 && icon != null) {
        // for some tables we combine (concatenate) the issue icon with an entity icon
        if (tableModel instanceof SpatialProcessTableModel) {
            Icon icon2 = null;
            SpatialProcess spatialProcess = (SpatialProcess) (((SpatialProcessTableModel) tableModel).getValueAt(row));
            if (spatialProcess instanceof PointLocation) {
                icon2 = VCellIcons.spatialLocationIcon;
            } else if (spatialProcess instanceof PointKinematics) {
                icon2 = VCellIcons.spatialKinematicsIcon;
            } else if (spatialProcess instanceof SurfaceKinematics) {
                icon2 = VCellIcons.spatialKinematicsIcon;
            } else {
                icon2 = VCellIcons.spatialKinematicsIcon;
            }
            icon = VCellIcons.addIcon(icon, icon2);
        } else if (tableModel instanceof SpatialObjectTableModel) {
            Icon icon2 = null;
            SpatialObject spatialObject = (SpatialObject) (((SpatialObjectTableModel) tableModel).getValueAt(row));
            if (spatialObject instanceof PointObject) {
                icon2 = VCellIcons.spatialPointIcon;
            } else if (spatialObject instanceof SurfaceRegionObject) {
                icon2 = VCellIcons.spatialMembraneIcon;
            } else if (spatialObject instanceof VolumeRegionObject) {
                icon2 = VCellIcons.spatialVolumeIcon;
            } else {
                icon2 = VCellIcons.spatialVolumeIcon;
            }
            icon = VCellIcons.addIcon(icon, icon2);
        }
    }
    renderer.setIcon(icon);
}
Also used : VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) Issue(org.vcell.util.Issue) PointLocation(cbit.vcell.mapping.spatial.processes.PointLocation) SurfaceKinematics(cbit.vcell.mapping.spatial.processes.SurfaceKinematics) Color(java.awt.Color) Point(java.awt.Point) SpatialObjectTableModel(cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) MatteBorder(javax.swing.border.MatteBorder) PointObject(cbit.vcell.mapping.spatial.PointObject) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) PointKinematics(cbit.vcell.mapping.spatial.processes.PointKinematics) Icon(javax.swing.Icon) SpatialProcessTableModel(cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject)

Aggregations

MatteBorder (javax.swing.border.MatteBorder)12 Color (java.awt.Color)5 Dimension (java.awt.Dimension)5 Insets (java.awt.Insets)4 Icon (javax.swing.Icon)3 JLabel (javax.swing.JLabel)3 EmptyBorder (javax.swing.border.EmptyBorder)3 Issue (org.vcell.util.Issue)3 Component (java.awt.Component)2 ImageIcon (javax.swing.ImageIcon)2 CompoundBorder (javax.swing.border.CompoundBorder)2 ScopedExpression (cbit.gui.ScopedExpression)1 SpatialObjectTableModel (cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel)1 SpatialProcessTableModel (cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel)1 VCellSortTableModel (cbit.vcell.client.desktop.biomodel.VCellSortTableModel)1 GeometryClass (cbit.vcell.geometry.GeometryClass)1 SubVolume (cbit.vcell.geometry.SubVolume)1 SurfaceClass (cbit.vcell.geometry.SurfaceClass)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1 SpeciesContextSpecParameter (cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter)1