Skip to content

Commit

Permalink
WIP: molecular structure panel, renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
danv61 committed Oct 31, 2024
1 parent 5d7bf8f commit f2356e4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cbit.vcell.client.desktop.biomodel.IssueManager;
import cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveViewID;
import cbit.vcell.client.desktop.biomodel.VCellSortTableModel;
import cbit.vcell.graph.GraphConstants;
import cbit.vcell.graph.SmallShapeManager;
import cbit.vcell.graph.SpeciesPatternSmallShape;
import cbit.vcell.mapping.*;
Expand Down Expand Up @@ -554,16 +555,14 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
};
// The Expression cell renderer in the MolecularTypeSpecsTable
DefaultScrollTableCellRenderer expressionTableCellRenderer = new DefaultScrollTableCellRenderer() {
final String darkRed = "#8B0000";
final String brown = "#A52A2A";
String darkRed = NamedColor.getHex(GraphConstants.darkred); // "#8B0000"
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (table.getModel() instanceof MolecularTypeSpecsTableModel) {
MolecularTypeSpecsTableModel model = (MolecularTypeSpecsTableModel)table.getModel();
if (value instanceof Double) {
String columnName = model.getColumnName(column);
if(MolecularTypeSpecsTableModel.ColumnType.COLUMN_RADIUS.ordinal() == column) {
if(!isSelected) {
String text = "<html>" + value + "<span style='color:" + darkRed + ";'> [nm]</span></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@

package org.vcell.util.springsalad;

import cbit.vcell.graph.GraphConstants;

import java.awt.Color;
import java.io.Serializable;

/*
* Springsalad-style colors.
* See also Colors
* For vcell-style colors see GraphConstants
*/
@SuppressWarnings("serial")
public class NamedColor implements Serializable {

private final Color color;
private final String name;

Expand Down Expand Up @@ -48,4 +56,34 @@ public static Color darker(Color color, double factor) {
color.getAlpha());
}

public String getHex() {
Color c = getColor();
String hex = getHex(c);
return hex;
}
public static String getHex(Color c) {
String hex = String.format("#%02x%02x%02x", c.getRed(), c.getGreen(), c.getBlue());
return hex;
}

public static void main(String[] args) {

Color red = Color.decode("#FF0000");
Color red1 = new Color(255, 0, 0, 32);
Color red2 = new Color(255, 0, 0, 127);
Color red3 = new Color(255, 0, 0, 255); // plain red

// some alpha manipulation
Color darkred = GraphConstants.darkred; // #8b0000
Color darkred1 = new Color(139, 0, 0, 32);
Color darkred2 = new Color(139, 0, 0, 127);
Color darkred3 = new Color(139, 0, 0, 255); // plain darkred

Color brown = Color.decode("#A52A2A");
Color brown1 = new Color(165, 42, 42, 32);
Color brown2 = new Color(165, 42, 42, 127);
Color brown3 = new Color(165, 42, 42, 255); // plain brown

}

}

0 comments on commit f2356e4

Please sign in to comment.