Commit 29fca608 authored by claes's avatar claes

Table object implemented

parent b75b2a03
......@@ -28,6 +28,7 @@ public class GeDyn {
public static final int mDynType_FillLevel = 1 << 21;
public static final int mDynType_FastCurve = 1 << 22;
public static final int mDynType_AnalogText = 1 << 23;
public static final int mDynType_Table = 1 << 24;
public static final int mActionType_No = 0;
public static final int mActionType_Inherit = 1 << 0;
......
package jpwr.jop;
import jpwr.rt.*;
import java.awt.*;
import java.awt.event.*;
public class GeDynTable extends GeDynElem {
public String[] attribute;
public String[] selAttribute;
int rows;
int columns;
public GeCFormat[] cFormat;
public boolean[] attrFound;
public boolean[] selAttrFound;
PwrtRefId[] subid;
int[] p;
public int[] typeId;
public boolean[][] oldValueB;
public float[][] oldValueF;
public int[][] oldValueI;
public String[][] oldValueS;
boolean firstScan = true;
StringBuffer sb = new StringBuffer();
public GeDynTable( GeDyn dyn, String[] attribute, String[] format, String[] selAttribute,
int rows, int columns) {
super( dyn, GeDyn.mDynType_Table, GeDyn.mActionType_No);
this.rows = rows;
this.columns = columns;
this.attribute = attribute;
this.selAttribute = selAttribute;
cFormat = new GeCFormat[columns];
for ( int i = 0; i < columns; i++)
cFormat[i] = new GeCFormat( format[i]);
p = new int[columns];
subid = new PwrtRefId[columns];
typeId = new int[columns];
attrFound = new boolean[columns];
selAttrFound = new boolean[columns];
oldValueB = new boolean[columns][];
oldValueF = new float[columns][];
oldValueI = new int[columns][];
oldValueS = new String[columns][];
}
public void connect() {
for ( int i = 0; i < columns; i++) {
String attrName = dyn.getAttrName( attribute[i]);
if ( attrName.compareTo("") != 0) {
GdhrRefObjectInfo ret = dyn.en.gdh.refObjectInfo( attrName);
if ( ret.evenSts()) {
System.out.println( "Table: " + attrName);
attrFound[i] = false;
}
else {
attrFound[i] = true;
p[i] = ret.id;
subid[i] = ret.refid;
typeId[i] = ret.typeId;
if ( typeId[i] == Pwr.eType_Float32) {
oldValueF[i] = new float[rows];
}
else if ( typeId[i] == Pwr.eType_Boolean) {
oldValueB[i] = new boolean[rows];
}
else if ( typeId[i] == Pwr.eType_Int32 ||
typeId[i] == Pwr.eType_UInt32 ||
typeId[i] == Pwr.eType_Int16 ||
typeId[i] == Pwr.eType_UInt16 ||
typeId[i] == Pwr.eType_Int8 ||
typeId[i] == Pwr.eType_UInt8) {
oldValueI[i] = new int[rows];
}
else if ( typeId[i] == Pwr.eType_String ||
typeId[i] == Pwr.eType_Objid) {
oldValueS[i] = new String[rows];
}
}
}
}
}
public void disconnect() {
for ( int i = 0; i < columns; i++) {
if ( attrFound[i])
dyn.en.gdh.unrefObjectInfo( subid[i]);
}
}
public void scan() {
for ( int i = 0; i < columns; i++) {
if ( !attrFound[i])
continue;
if ( typeId[i] == Pwr.eType_Float32) {
float value0 = dyn.en.gdh.getObjectRefInfoFloat( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueF[i][j] || firstScan) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueF[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_Boolean) {
boolean value0 = dyn.en.gdh.getObjectRefInfoBoolean( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueB[i][j] || firstScan) {
if ( value0)
((GeTable)dyn.comp).setValueAt("1", j, i);
else
((GeTable)dyn.comp).setValueAt("0", j, i);
// dyn.repaintNow = true;
oldValueB[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_Int32 ||
typeId[i] == Pwr.eType_UInt32 ||
typeId[i] == Pwr.eType_Int16 ||
typeId[i] == Pwr.eType_UInt16 ||
typeId[i] == Pwr.eType_Int8 ||
typeId[i] == Pwr.eType_UInt8) {
int value0 = dyn.en.gdh.getObjectRefInfoInt( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueI[i][j] || firstScan) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueI[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_String ||
typeId[i] == Pwr.eType_Objid) {
String value0 = dyn.en.gdh.getObjectRefInfoString( p[i], typeId[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( firstScan || value0.compareTo( oldValueS[i][j]) != 0) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueS[i][j] = value0;
}
}
}
if ( firstScan)
firstScan = false;
}
}
public void action( int eventType, MouseEvent e) {
int row;
int column;
switch ( eventType) {
case GeDyn.eEvent_MB1Click:
column = ((GeTable)dyn.comp).getSelectedColumn();
row = ((GeTable)dyn.comp).getSelectedRow();
System.out.println( "MB1Click " + row + " " + column);
break;
case GeDyn.eEvent_MB3Press:
System.out.println("mb3 press");
// Get the selected object
column = ((GeTable)dyn.comp).getSelectedColumn();
row = ((GeTable)dyn.comp).getSelectedRow();
System.out.println("Row " + row + " Column " + column);
if ( row == -1 || column == -1)
break;
if ( typeId[column] == Pwr.eType_Objid) {
// Name of an attribute that contains the objid of the reference object
String name = dyn.getAttrNameNoSuffix( attribute[column]);
name = name + "[" + row + "]";
CdhrObjid reto = dyn.en.gdh.getObjectInfoObjid( name);
if ( reto.oddSts() && !reto.objid.isNull()) {
CdhrString rets = dyn.en.gdh.objidToName( reto.objid, Cdh.mName_volumeStrict);
System.out.println( "str: " + rets.str + " " + rets.getSts());
if ( rets.oddSts() && ! rets.str.equals(""))
new JopMethodsMenu( dyn.session, rets.str, JopUtility.GRAPH,
(Component)dyn.comp, e.getX(), e.getY());
}
}
break;
}
}
}
package jpwr.jop;
import jpwr.rt.*;
import jpwr.jop.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.Timer;
import javax.swing.table.*;
import javax.swing.event.*;
public class GeTable extends JScrollPane implements GeComponentIfc,
JopDynamic, ActionListener, ListSelectionListener
{
Dimension size;
Object root;
Timer timer = new Timer(500, this);
JopSession session;
public JopEngine en;
public GeDyn dd = new GeDyn( this);
JTable table;
JTable headerColumn;
int rows;
int columns;
int hRow;
int hColumn;
JViewport jv;
public boolean focus = false;
public boolean confirmActive = false;
public Color normalColor = null;
public GeTable component = this;
public GeTable( JopSession session, int rows, int columns, int hRow, int hColumn)
{
this.session = session;
dd.setSession( session);
size = new Dimension( 102, 36);
timer.start();
this.rows = rows;
this.columns = columns;
this.hRow = hRow;
this.hColumn = hColumn;
table = new JTable( rows, columns - hColumn);
table.setColumnSelectionAllowed( false);
table.setRowSelectionAllowed( false);
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
if ( hRow == 0) {
table.setTableHeader( null);
}
if ( hColumn == 1) {
// Set up the header column
headerColumn = new JTable(rows, 1);
table.setSelectionModel( headerColumn.getSelectionModel());
headerColumn.setMaximumSize( new Dimension( 90, 10000));
headerColumn.setColumnSelectionAllowed( false);
headerColumn.setRowSelectionAllowed( false);
// headerColumn.setCellSelectionEnabled( false);
jv = new JViewport();
jv.setView( headerColumn);
jv.setPreferredSize( headerColumn.getMaximumSize());
table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF);
headerColumn.setAutoResizeMode( JTable.AUTO_RESIZE_OFF);
getViewport().setView(table);
setRowHeader( jv);
}
else {
table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF);
getViewport().setView(table);
}
}
public void setHeaderText( int idx, String text) {
if ( idx == 0 && hColumn == 1) {
// Header of header row is not supported...
}
else if ( hRow != 0)
table.getColumnModel().getColumn(idx - hColumn).setHeaderValue( text);
}
public void setColumnWidth( int idx, int width) {
if ( idx == 0 && hColumn == 1) {
headerColumn.getColumnModel().getColumn(0).setPreferredWidth( width);
jv.setPreferredSize( new Dimension( width, 10000));
}
else
table.getColumnModel().getColumn(idx - hColumn).setPreferredWidth( width);
}
public void setRowHeight( int height) {
table.setRowHeight( height);
if ( hColumn == 1)
headerColumn.setRowHeight( height);
}
public void setHeaderRowHeight( int height) {
}
public void setFont( Font font) {
if ( table != null)
table.setFont( font);
if ( hColumn == 1 && headerColumn != null)
headerColumn.setFont( font);
}
public void setValueAt( String value, int row, int column) {
if ( column == 0 && hColumn == 1)
headerColumn.setValueAt( value, row, column);
else
table.setValueAt( value, row, column - hColumn);
}
public int getSelectedRow() {
int row = table.getSelectedRow();
if ( row == -1 && hColumn == 1)
row = headerColumn.getSelectedRow();
return row;
}
public int getSelectedColumn() {
int column;
if ( hColumn == 1)
// Always return header column
column = 0;
else
column = table.getSelectedColumn();
return column;
}
public void actionPerformed(ActionEvent e) {
boolean engine_found = false;
root = getTopLevelAncestor();
if ( root != null) {
if ( root instanceof JopApplet)
session = ((JopApplet)root).session;
else if ( root instanceof JopFrame)
session = ((JopFrame) root).session;
en = session.getEngine();
if ( !en.isReady())
return;
en.add(this);
engine_found = true;
}
if ( engine_found) {
timer.stop();
timer = null;
if ( en.gdh.isAuthorized( dd.access)) {
table.getSelectionModel().addListSelectionListener( this);
table.getColumnModel().getSelectionModel().addListSelectionListener( this);
table.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
if ( e.isPopupTrigger())
dd.action( GeDyn.eEvent_MB3Press, e);
}
public void mousePressed(MouseEvent e) {
if ( e.isPopupTrigger())
dd.action( GeDyn.eEvent_MB3Press, e);
}
});
if ( hColumn == 1) {
headerColumn.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
if ( e.isPopupTrigger())
dd.action( GeDyn.eEvent_MB3Press, e);
}
public void mousePressed(MouseEvent e) {
if ( e.isPopupTrigger())
dd.action( GeDyn.eEvent_MB3Press, e);
}
});
}
}
}
}
public void valueChanged(ListSelectionEvent e) {
MouseEvent me = new MouseEvent( this, 0,0,0,0,0,0,false);
dd.action( GeDyn.eEvent_MB1Click, me);
}
// GeComponents Ifc
public void tsetFillColor( int fillColor) {
this.fillColor = fillColor;
normalColor = GeColor.getColor( fillColor, colorTone,
colorShift, colorIntensity, colorBrightness, colorInverse, fillColor);
table.setBackground( normalColor);
if ( hColumn == 1)
headerColumn.setBackground( normalColor);
}
public void tsetColorTone( int colorTone) {
this.colorTone = colorTone;
normalColor = GeColor.getColor( fillColor, colorTone,
colorShift, colorIntensity, colorBrightness, colorInverse, GeColor.NO_COLOR);
table.setBackground( normalColor);
if ( hColumn == 1)
headerColumn.setBackground( normalColor);
}
public void tsetBorderColor( int borderColor) {}
public void tsetTextColor( int borderColor) {}
public void setColorInverse( int colorInverse) {}
public void resetFillColor() {
fillColor = originalFillColor;
normalColor = GeColor.getColor( fillColor, colorTone,
colorShift, colorIntensity, colorBrightness, colorInverse, fillColor);
table.setBackground( normalColor);
if ( hColumn == 1)
headerColumn.setBackground( normalColor);
}
public void resetColorTone() {
colorTone = originalColorTone;
normalColor = GeColor.getColor( fillColor, colorTone,
colorShift, colorIntensity, colorBrightness, colorInverse, fillColor);
table.setBackground( normalColor);
if ( hColumn == 1)
headerColumn.setBackground( normalColor);
}
public void resetBorderColor() {}
public void resetTextColor() {}
public String getAnnot1() { return "";}
public void setAnnot1( String s) {}
public void setLastPage() {}
public void setFirstPage() {}
public void setPage( int page) {}
public int setNextPage() { return 1;}
public int setPreviousPage() { return 1;}
public Object getDd() { return dd;}
public void setFillLevel( float fillLevel) {}
public void setLevelDirection( int levelDirection) {}
public void setLevelColorTone( int levelColorTone) {}
public void setLevelFillColor( int levelFillColor) {}
Font cellFont = new Font("Helvetica", Font.BOLD, 14);
public void setCellFont( Font font) { cellFont = font; setFont(font);}
public Font getCellFont() { return cellFont;}
public int fillColor = 9999;
public int originalFillColor = 9999;
public int borderColor = 9999;
public int originalBorderColor = 9999;
public int colorTone = 0;
public int originalColorTone = 0;
public int colorShift = 0;
public int originalColorShift = 0;
public int colorBrightness = 0;
public int originalColorBrightness = 0;
public int colorIntensity = 0;
public int originalColorIntensity = 0;
public int colorInverse = 0;
public int originalColorInverse = 0;
public void setColorTone( int colorTone) {
this.colorTone = colorTone;
originalColorTone = colorTone;
}
public int getColorTone() {
return colorTone;
}
public void setColorShift( int colorShift) {
this.colorShift = colorShift;
originalColorShift = colorShift;
}
public int getColorShift() {
return colorShift;
}
public void setColorBrightness( int colorBrightness) {
this.colorBrightness = colorBrightness;
originalColorBrightness = colorBrightness;
}
public int getColorBrightness() {
return colorBrightness;
}
public void setColorIntensity( int colorIntensity) {
this.colorIntensity = colorIntensity;
originalColorIntensity = colorIntensity;
}
public int getColorIntensity() {
return colorIntensity;
}
public void setFillColor( int fillColor) {
this.fillColor = fillColor;
this.originalFillColor = fillColor;
}
public int getFillColor() {
return fillColor;
}
public void setBorderColor( int borderColor) {
this.borderColor = borderColor;
this.originalBorderColor = borderColor;
}
public int getBorderColor() {
return borderColor;
}
public double rotate;
public void setRotate( double rotate) {}
public double getRotate() { return rotate;}
public Object dynamicGetRoot() {
return root;
}
public void dynamicOpen() {
if ( en.isInstance())
dd.setInstance( en.getInstance());
dd.connect();
normalColor = GeColor.getColor( fillColor, colorTone,
colorShift, colorIntensity, colorBrightness, colorInverse, fillColor);
table.setBackground( normalColor);
if ( hColumn == 1)
headerColumn.setBackground( normalColor);
}
public void dynamicClose() {
dd.disconnect();
}
public void dynamicUpdate( boolean animationOnly) {
if ( animationOnly || focus)
return;
dd.scan();
}
public void repaintForeground() {
Graphics g = getGraphics();
if ( g == null) {
System.out.println("repaintForeground: can't get Graphic object");
return;
}
paintComponent(g);
paintChildren(g);
}
}
......@@ -28,6 +28,7 @@ public class GeDyn {
public static final int mDynType_FillLevel = 1 << 21;
public static final int mDynType_FastCurve = 1 << 22;
public static final int mDynType_AnalogText = 1 << 23;
public static final int mDynType_Table = 1 << 24;
public static final int mActionType_No = 0;
public static final int mActionType_Inherit = 1 << 0;
......
package jpwr.jop;
import jpwr.rt.*;
import java.awt.*;
import java.awt.event.*;
public class GeDynTable extends GeDynElem {
public String[] attribute;
public String[] selAttribute;
int rows;
int columns;
public GeCFormat[] cFormat;
public boolean[] attrFound;
public boolean[] selAttrFound;
PwrtRefId[] subid;
int[] p;
public int[] typeId;
public boolean[][] oldValueB;
public float[][] oldValueF;
public int[][] oldValueI;
public String[][] oldValueS;
boolean firstScan = true;
StringBuffer sb = new StringBuffer();
public GeDynTable( GeDyn dyn, String[] attribute, String[] format, String[] selAttribute,
int rows, int columns) {
super( dyn, GeDyn.mDynType_Table, GeDyn.mActionType_No);
this.rows = rows;
this.columns = columns;
this.attribute = attribute;
this.selAttribute = selAttribute;
cFormat = new GeCFormat[columns];
for ( int i = 0; i < columns; i++)
cFormat[i] = new GeCFormat( format[i]);
p = new int[columns];
subid = new PwrtRefId[columns];
typeId = new int[columns];
attrFound = new boolean[columns];
selAttrFound = new boolean[columns];
oldValueB = new boolean[columns][];
oldValueF = new float[columns][];
oldValueI = new int[columns][];
oldValueS = new String[columns][];
}
public void connect() {
for ( int i = 0; i < columns; i++) {
String attrName = dyn.getAttrName( attribute[i]);
if ( attrName.compareTo("") != 0) {
GdhrRefObjectInfo ret = dyn.en.gdh.refObjectInfo( attrName);
if ( ret.evenSts()) {
System.out.println( "Table: " + attrName);
attrFound[i] = false;
}
else {
attrFound[i] = true;
p[i] = ret.id;
subid[i] = ret.refid;
typeId[i] = ret.typeId;
if ( typeId[i] == Pwr.eType_Float32) {
oldValueF[i] = new float[rows];
}
else if ( typeId[i] == Pwr.eType_Boolean) {
oldValueB[i] = new boolean[rows];
}
else if ( typeId[i] == Pwr.eType_Int32 ||
typeId[i] == Pwr.eType_UInt32 ||
typeId[i] == Pwr.eType_Int16 ||
typeId[i] == Pwr.eType_UInt16 ||
typeId[i] == Pwr.eType_Int8 ||
typeId[i] == Pwr.eType_UInt8) {
oldValueI[i] = new int[rows];
}
else if ( typeId[i] == Pwr.eType_String ||
typeId[i] == Pwr.eType_Objid) {
oldValueS[i] = new String[rows];
}
}
}
}
}
public void disconnect() {
for ( int i = 0; i < columns; i++) {
if ( attrFound[i])
dyn.en.gdh.unrefObjectInfo( subid[i]);
}
}
public void scan() {
for ( int i = 0; i < columns; i++) {
if ( !attrFound[i])
continue;
if ( typeId[i] == Pwr.eType_Float32) {
float value0 = dyn.en.gdh.getObjectRefInfoFloat( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueF[i][j] || firstScan) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueF[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_Boolean) {
boolean value0 = dyn.en.gdh.getObjectRefInfoBoolean( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueB[i][j] || firstScan) {
if ( value0)
((GeTable)dyn.comp).setValueAt("1", j, i);
else
((GeTable)dyn.comp).setValueAt("0", j, i);
// dyn.repaintNow = true;
oldValueB[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_Int32 ||
typeId[i] == Pwr.eType_UInt32 ||
typeId[i] == Pwr.eType_Int16 ||
typeId[i] == Pwr.eType_UInt16 ||
typeId[i] == Pwr.eType_Int8 ||
typeId[i] == Pwr.eType_UInt8) {
int value0 = dyn.en.gdh.getObjectRefInfoInt( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueI[i][j] || firstScan) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueI[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_String ||
typeId[i] == Pwr.eType_Objid) {
String value0 = dyn.en.gdh.getObjectRefInfoString( p[i], typeId[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( firstScan || value0.compareTo( oldValueS[i][j]) != 0) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueS[i][j] = value0;
}
}
}
if ( firstScan)
firstScan = false;
}
}
public void action( int eventType, MouseEvent e) {
int row;
int column;
switch ( eventType) {
case GeDyn.eEvent_MB1Click:
column = ((GeTable)dyn.comp).getSelectedColumn();
row = ((GeTable)dyn.comp).getSelectedRow();
System.out.println( "MB1Click " + row + " " + column);
break;
case GeDyn.eEvent_MB3Press:
System.out.println("mb3 press");
// Get the selected object
column = ((GeTable)dyn.comp).getSelectedColumn();
row = ((GeTable)dyn.comp).getSelectedRow();
System.out.println("Row " + row + " Column " + column);
if ( row == -1 || column == -1)
break;
if ( typeId[column] == Pwr.eType_Objid) {
// Name of an attribute that contains the objid of the reference object
String name = dyn.getAttrNameNoSuffix( attribute[column]);
name = name + "[" + row + "]";
CdhrObjid reto = dyn.en.gdh.getObjectInfoObjid( name);
if ( reto.oddSts() && !reto.objid.isNull()) {
CdhrString rets = dyn.en.gdh.objidToName( reto.objid, Cdh.mName_volumeStrict);
System.out.println( "str: " + rets.str + " " + rets.getSts());
if ( rets.oddSts() && ! rets.str.equals(""))
new JopMethodsMenu( dyn.session, rets.str, JopUtility.GRAPH,
(Component)dyn.comp, e.getX(), e.getY());
}
}
break;
}
}
}
package jpwr.jop;
import jpwr.rt.*;
import jpwr.jop.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.Timer;
import javax.swing.table.*;
import javax.swing.event.*;
public class GeTable extends JScrollPane implements GeComponentIfc,
JopDynamic, ActionListener, ListSelectionListener
{
Dimension size;
Object root;
Timer timer = new Timer(500, this);
JopSession session;
public JopEngine en;
public GeDyn dd = new GeDyn( this);
JTable table;
JTable headerColumn;
int rows;
int columns;
int hRow;
int hColumn;
JViewport jv;
public boolean focus = false;
public boolean confirmActive = false;
public Color normalColor = null;
public GeTable component = this;
public GeTable( JopSession session, int rows, int columns, int hRow, int hColumn)
{
this.session = session;
dd.setSession( session);
size = new Dimension( 102, 36);
timer.start();
this.rows = rows;
this.columns = columns;
this.hRow = hRow;
this.hColumn = hColumn;
table = new JTable( rows, columns - hColumn);
table.setColumnSelectionAllowed( false);
table.setRowSelectionAllowed( false);
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
if ( hRow == 0) {
table.setTableHeader( null);
}
if ( hColumn == 1) {
// Set up the header column
headerColumn = new JTable(rows, 1);
table.setSelectionModel( headerColumn.getSelectionModel());
headerColumn.setMaximumSize( new Dimension( 90, 10000));
headerColumn.setColumnSelectionAllowed( false);
headerColumn.setRowSelectionAllowed( false);
// headerColumn.setCellSelectionEnabled( false);
jv = new JViewport();
jv.setView( headerColumn);
jv.setPreferredSize( headerColumn.getMaximumSize());
table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF);
headerColumn.setAutoResizeMode( JTable.AUTO_RESIZE_OFF);
getViewport().setView(table);
setRowHeader( jv);
}
else {
table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF);
getViewport().setView(table);
}
}
public void setHeaderText( int idx, String text) {
if ( idx == 0 && hColumn == 1) {
// Header of header row is not supported...
}
else if ( hRow != 0)
table.getColumnModel().getColumn(idx - hColumn).setHeaderValue( text);
}
public void setColumnWidth( int idx, int width) {
if ( idx == 0 && hColumn == 1) {
headerColumn.getColumnModel().getColumn(0).setPreferredWidth( width);
jv.setPreferredSize( new Dimension( width, 10000));
}
else
table.getColumnModel().getColumn(idx - hColumn).setPreferredWidth( width);
}
public void setRowHeight( int height) {
table.setRowHeight( height);
if ( hColumn == 1)
headerColumn.setRowHeight( height);
}
public void setHeaderRowHeight( int height) {
}
public void setFont( Font font) {
if ( table != null)
table.setFont( font);
if ( hColumn == 1 && headerColumn != null)
headerColumn.setFont( font);
}
public void setValueAt( String value, int row, int column) {
if ( column == 0 && hColumn == 1)
headerColumn.setValueAt( value, row, column);
else
table.setValueAt( value, row, column - hColumn);
}
public int getSelectedRow() {
int row = table.getSelectedRow();
if ( row == -1 && hColumn == 1)
row = headerColumn.getSelectedRow();
return row;
}
public int getSelectedColumn() {
int column;
if ( hColumn == 1)
// Always return header column
column = 0;
else
column = table.getSelectedColumn();
return column;
}
public void actionPerformed(ActionEvent e) {
boolean engine_found = false;
root = getTopLevelAncestor();
if ( root != null) {
if ( root instanceof JopApplet)
session = ((JopApplet)root).session;
else if ( root instanceof JopFrame)
session = ((JopFrame) root).session;
en = session.getEngine();
if ( !en.isReady())
return;
en.add(this);
engine_found = true;
}
if ( engine_found) {
timer.stop();
timer = null;
if ( en.gdh.isAuthorized( dd.access)) {
table.getSelectionModel().addListSelectionListener( this);
table.getColumnModel().getSelectionModel().addListSelectionListener( this);
table.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
if ( e.isPopupTrigger())
dd.action( GeDyn.eEvent_MB3Press, e);
}
public void mousePressed(MouseEvent e) {
if ( e.isPopupTrigger())
dd.action( GeDyn.eEvent_MB3Press, e);
}
});
if ( hColumn == 1) {
headerColumn.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
if ( e.isPopupTrigger())
dd.action( GeDyn.eEvent_MB3Press, e);
}
public void mousePressed(MouseEvent e) {
if ( e.isPopupTrigger())
dd.action( GeDyn.eEvent_MB3Press, e);
}
});
}
}
}
}
public void valueChanged(ListSelectionEvent e) {
MouseEvent me = new MouseEvent( this, 0,0,0,0,0,0,false);
dd.action( GeDyn.eEvent_MB1Click, me);
}
// GeComponents Ifc
public void tsetFillColor( int fillColor) {
this.fillColor = fillColor;
normalColor = GeColor.getColor( fillColor, colorTone,
colorShift, colorIntensity, colorBrightness, colorInverse, fillColor);
table.setBackground( normalColor);
if ( hColumn == 1)
headerColumn.setBackground( normalColor);
}
public void tsetColorTone( int colorTone) {
this.colorTone = colorTone;
normalColor = GeColor.getColor( fillColor, colorTone,
colorShift, colorIntensity, colorBrightness, colorInverse, GeColor.NO_COLOR);
table.setBackground( normalColor);
if ( hColumn == 1)
headerColumn.setBackground( normalColor);
}
public void tsetBorderColor( int borderColor) {}
public void tsetTextColor( int borderColor) {}
public void setColorInverse( int colorInverse) {}
public void resetFillColor() {
fillColor = originalFillColor;
normalColor = GeColor.getColor( fillColor, colorTone,
colorShift, colorIntensity, colorBrightness, colorInverse, fillColor);
table.setBackground( normalColor);
if ( hColumn == 1)
headerColumn.setBackground( normalColor);
}
public void resetColorTone() {
colorTone = originalColorTone;
normalColor = GeColor.getColor( fillColor, colorTone,
colorShift, colorIntensity, colorBrightness, colorInverse, fillColor);
table.setBackground( normalColor);
if ( hColumn == 1)
headerColumn.setBackground( normalColor);
}
public void resetBorderColor() {}
public void resetTextColor() {}
public String getAnnot1() { return "";}
public void setAnnot1( String s) {}
public void setLastPage() {}
public void setFirstPage() {}
public void setPage( int page) {}
public int setNextPage() { return 1;}
public int setPreviousPage() { return 1;}
public Object getDd() { return dd;}
public void setFillLevel( float fillLevel) {}
public void setLevelDirection( int levelDirection) {}
public void setLevelColorTone( int levelColorTone) {}
public void setLevelFillColor( int levelFillColor) {}
Font cellFont = new Font("Helvetica", Font.BOLD, 14);
public void setCellFont( Font font) { cellFont = font; setFont(font);}
public Font getCellFont() { return cellFont;}
public int fillColor = 9999;
public int originalFillColor = 9999;
public int borderColor = 9999;
public int originalBorderColor = 9999;
public int colorTone = 0;
public int originalColorTone = 0;
public int colorShift = 0;
public int originalColorShift = 0;
public int colorBrightness = 0;
public int originalColorBrightness = 0;
public int colorIntensity = 0;
public int originalColorIntensity = 0;
public int colorInverse = 0;
public int originalColorInverse = 0;
public void setColorTone( int colorTone) {
this.colorTone = colorTone;
originalColorTone = colorTone;
}
public int getColorTone() {
return colorTone;
}
public void setColorShift( int colorShift) {
this.colorShift = colorShift;
originalColorShift = colorShift;
}
public int getColorShift() {
return colorShift;
}
public void setColorBrightness( int colorBrightness) {
this.colorBrightness = colorBrightness;
originalColorBrightness = colorBrightness;
}
public int getColorBrightness() {
return colorBrightness;
}
public void setColorIntensity( int colorIntensity) {
this.colorIntensity = colorIntensity;
originalColorIntensity = colorIntensity;
}
public int getColorIntensity() {
return colorIntensity;
}
public void setFillColor( int fillColor) {
this.fillColor = fillColor;
this.originalFillColor = fillColor;
}
public int getFillColor() {
return fillColor;
}
public void setBorderColor( int borderColor) {
this.borderColor = borderColor;
this.originalBorderColor = borderColor;
}
public int getBorderColor() {
return borderColor;
}
public double rotate;
public void setRotate( double rotate) {}
public double getRotate() { return rotate;}
public Object dynamicGetRoot() {
return root;
}
public void dynamicOpen() {
if ( en.isInstance())
dd.setInstance( en.getInstance());
dd.connect();
normalColor = GeColor.getColor( fillColor, colorTone,
colorShift, colorIntensity, colorBrightness, colorInverse, fillColor);
table.setBackground( normalColor);
if ( hColumn == 1)
headerColumn.setBackground( normalColor);
}
public void dynamicClose() {
dd.disconnect();
}
public void dynamicUpdate( boolean animationOnly) {
if ( animationOnly || focus)
return;
dd.scan();
}
public void repaintForeground() {
Graphics g = getGraphics();
if ( g == null) {
System.out.println("repaintForeground: can't get Graphic object");
return;
}
paintComponent(g);
paintChildren(g);
}
}
......@@ -27,6 +27,7 @@ local_java_sources := \
JopBar.java \
JopTrend.java \
JopAxis.java \
GeTable.java \
GeDynElem.java \
GeDynDigLowColor.java \
GeDynDigColor.java \
......@@ -60,6 +61,7 @@ local_java_sources := \
GeDynPulldownMenu.java \
GeDynOptionMenu.java \
GeDynAnalogText.java \
GeDynTable.java \
JopSpiderFrame.java \
JopLoginFrame.java \
JopLoginApplet.java \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment