mirror of https://github.com/rusefi/RomRaider.git
Fixed packages decs -- come on Eclipse :(
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@528 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
95f71e12c7
commit
c757cb403c
|
@ -19,16 +19,16 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package enginuity.newmaps.gui;
|
package enginuity.newmaps.swing;
|
||||||
|
|
||||||
import enginuity.newmaps.ecumetadata.TableMetadata;
|
import enginuity.newmaps.ecumetadata.TableMetadata;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
public abstract class EnginuityFrame extends JFrame {
|
public abstract class EnginuityFrame extends JFrame {
|
||||||
|
|
||||||
public EnginuityFrame(byte[] data, TableMetadata metadata) {
|
public EnginuityFrame(byte[] data, TableMetadata metadata) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package enginuity.newmaps.gui;
|
package enginuity.newmaps.swing;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
|
@ -17,75 +17,75 @@ import javax.swing.JTable;
|
||||||
public class EnginuityJTable extends JTable
|
public class EnginuityJTable extends JTable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
HashSet<Point> cellSelection = new HashSet<Point>();
|
HashSet<Point> cellSelection = new HashSet<Point>();
|
||||||
HashSet<Point> currentSelection = new HashSet<Point>();
|
HashSet<Point> currentSelection = new HashSet<Point>();
|
||||||
HashSet<Cell> clipBoard = new HashSet<Cell>();
|
HashSet<Cell> clipBoard = new HashSet<Cell>();
|
||||||
Point lastSelectedCell = null;
|
Point lastSelectedCell = null;
|
||||||
Point currentSelectedCell = null;
|
Point currentSelectedCell = null;
|
||||||
|
|
||||||
|
|
||||||
private Color oldSelectionBackgroundColor;
|
private Color oldSelectionBackgroundColor;
|
||||||
private Color copySelectionColour = Color.red;
|
private Color copySelectionColour = Color.red;
|
||||||
private Color cutSelectionColour = Color.yellow;
|
private Color cutSelectionColour = Color.yellow;
|
||||||
|
|
||||||
|
|
||||||
private boolean check = false;
|
private boolean check = false;
|
||||||
|
|
||||||
public static final int COPY = 1;
|
public static final int COPY = 1;
|
||||||
public static final int CUT = 2;
|
public static final int CUT = 2;
|
||||||
|
|
||||||
private int action;
|
private int action;
|
||||||
|
|
||||||
public EnginuityJTable(int rows, int columns)
|
public EnginuityJTable(int rows, int columns)
|
||||||
{
|
{
|
||||||
super (rows, columns);
|
super (rows, columns);
|
||||||
MouseMotionListener[] cls = (MouseMotionListener[])(this.getListeners(MouseMotionListener.class));
|
MouseMotionListener[] cls = (MouseMotionListener[])(this.getListeners(MouseMotionListener.class));
|
||||||
for ( int i = 0; i < cls.length; i++)
|
for ( int i = 0; i < cls.length; i++)
|
||||||
{
|
{
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
this.removeMouseMotionListener( cls[i] );
|
this.removeMouseMotionListener( cls[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addKeyListener( new EventKeyHandler(this) );
|
this.addKeyListener( new EventKeyHandler(this) );
|
||||||
this.addMouseMotionListener( new MouseMotionH(this) );
|
this.addMouseMotionListener( new MouseMotionH(this) );
|
||||||
this.setCellSelectionEnabled( true );
|
this.setCellSelectionEnabled( true );
|
||||||
this.setSelectionBackground( Color.blue );
|
this.setSelectionBackground( Color.blue );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void changeSelection(
|
public void changeSelection(
|
||||||
int row, int column, boolean toggle, boolean extend)
|
int row, int column, boolean toggle, boolean extend)
|
||||||
{
|
{
|
||||||
super.changeSelection(row, column, toggle, extend);
|
super.changeSelection(row, column, toggle, extend);
|
||||||
if (!check)
|
if (!check)
|
||||||
{
|
{
|
||||||
oldSelectionBackgroundColor = getSelectionBackground();
|
oldSelectionBackgroundColor = getSelectionBackground();
|
||||||
check = true;
|
check = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Don't think this makes sense
|
// Don't think this makes sense
|
||||||
if (toggle && extend)
|
if (toggle && extend)
|
||||||
{
|
{
|
||||||
//currentSelectedCell = new Point(row, column);
|
//currentSelectedCell = new Point(row, column);
|
||||||
extendCellSelection(row, column);
|
extendCellSelection(row, column);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toggle)
|
if (toggle)
|
||||||
{
|
{
|
||||||
if (currentSelectedCell!= null && !currentSelection.isEmpty())
|
if (currentSelectedCell!= null && !currentSelection.isEmpty())
|
||||||
{
|
{
|
||||||
cellSelection.addAll( currentSelection );
|
cellSelection.addAll( currentSelection );
|
||||||
currentSelection.clear();
|
currentSelection.clear();
|
||||||
}
|
}
|
||||||
toggleCellSelection(row, column);
|
toggleCellSelection(row, column);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extend)
|
if (extend)
|
||||||
{
|
{
|
||||||
extendCellSelection(row, column);
|
extendCellSelection(row, column);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ public class EnginuityJTable extends JTable
|
||||||
currentSelection.clear();
|
currentSelection.clear();
|
||||||
cellSelection.add(new Point(row, column));
|
cellSelection.add(new Point(row, column));
|
||||||
lastSelectedCell = new Point(row, column);
|
lastSelectedCell = new Point(row, column);
|
||||||
|
|
||||||
/*System.out.println(cellSelection);
|
/*System.out.println(cellSelection);
|
||||||
System.out.println(currentSelection);*/
|
System.out.println(currentSelection);*/
|
||||||
this.setSelectionBackground( oldSelectionBackgroundColor );
|
this.setSelectionBackground( oldSelectionBackgroundColor );
|
||||||
|
@ -116,12 +116,12 @@ public class EnginuityJTable extends JTable
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extendCellSelection(int row, int column)
|
private void extendCellSelection(int row, int column)
|
||||||
{
|
{
|
||||||
currentSelectedCell = new Point(row, column);
|
currentSelectedCell = new Point(row, column);
|
||||||
/*if a drag only into one cell*/
|
/*if a drag only into one cell*/
|
||||||
if (currentSelectedCell.equals( lastSelectedCell ))
|
if (currentSelectedCell.equals( lastSelectedCell ))
|
||||||
return;
|
return;
|
||||||
currentSelection.clear();
|
currentSelection.clear();
|
||||||
Point p = null;
|
Point p = null;
|
||||||
int minColumn;
|
int minColumn;
|
||||||
int minRow;
|
int minRow;
|
||||||
|
@ -137,7 +137,7 @@ public class EnginuityJTable extends JTable
|
||||||
minColumn = lastSelectedCell.y;
|
minColumn = lastSelectedCell.y;
|
||||||
maxColumn = currentSelectedCell.y;
|
maxColumn = currentSelectedCell.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentSelectedCell.x < lastSelectedCell.x)
|
if (currentSelectedCell.x < lastSelectedCell.x)
|
||||||
{
|
{
|
||||||
minRow = currentSelectedCell.x;
|
minRow = currentSelectedCell.x;
|
||||||
|
@ -149,20 +149,20 @@ public class EnginuityJTable extends JTable
|
||||||
maxRow = currentSelectedCell.x;
|
maxRow = currentSelectedCell.x;
|
||||||
}
|
}
|
||||||
for ( int i = minRow; i <= maxRow ; i++)
|
for ( int i = minRow; i <= maxRow ; i++)
|
||||||
{
|
{
|
||||||
for ( int j = minColumn; j <= maxColumn; j++)
|
for ( int j = minColumn; j <= maxColumn; j++)
|
||||||
{
|
{
|
||||||
p = new Point( i, j );
|
p = new Point( i, j );
|
||||||
currentSelection.add( p );
|
currentSelection.add( p );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCellSelected(int row, int column)
|
public boolean isCellSelected(int row, int column)
|
||||||
{
|
{
|
||||||
return (cellSelection.contains(new Point(row, column))) || (currentSelection.contains(new Point(row, column)));
|
return (cellSelection.contains(new Point(row, column))) || (currentSelection.contains(new Point(row, column)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ public class EnginuityJTable extends JTable
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getCurrentSelectedCell()
|
public Point getCurrentSelectedCell()
|
||||||
{
|
{
|
||||||
return currentSelectedCell;
|
return currentSelectedCell;
|
||||||
|
@ -194,7 +194,7 @@ public class EnginuityJTable extends JTable
|
||||||
public void setLastSelectedCell( Point lastSelectedCell )
|
public void setLastSelectedCell( Point lastSelectedCell )
|
||||||
{
|
{
|
||||||
this.lastSelectedCell = lastSelectedCell;
|
this.lastSelectedCell = lastSelectedCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public HashSet getCellSelection()
|
public HashSet getCellSelection()
|
||||||
|
@ -206,16 +206,16 @@ public class EnginuityJTable extends JTable
|
||||||
{
|
{
|
||||||
this.cellSelection = cellSelection;
|
this.cellSelection = cellSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearSelection( )
|
public void clearSelection( )
|
||||||
{
|
{
|
||||||
if ( cellSelection != null )
|
if ( cellSelection != null )
|
||||||
this.cellSelection.clear();
|
this.cellSelection.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The set with the selected cells copied do a new HashSet that playes the role of the clpiboard
|
* The set with the selected cells copied do a new HashSet that playes the role of the clpiboard
|
||||||
*/
|
*/
|
||||||
|
@ -226,25 +226,25 @@ public class EnginuityJTable extends JTable
|
||||||
|
|
||||||
public void toClipBoard( int cut )
|
public void toClipBoard( int cut )
|
||||||
{
|
{
|
||||||
Point cell = null;
|
Point cell = null;
|
||||||
HashSet<Point> clipBoardHS = new HashSet<Point>();
|
HashSet<Point> clipBoardHS = new HashSet<Point>();
|
||||||
|
|
||||||
this.clipBoard.clear();
|
this.clipBoard.clear();
|
||||||
clipBoardHS.addAll( cellSelection );
|
clipBoardHS.addAll( cellSelection );
|
||||||
clipBoardHS.addAll( currentSelection );
|
clipBoardHS.addAll( currentSelection );
|
||||||
|
|
||||||
for ( Iterator iter = clipBoardHS.iterator(); iter.hasNext();)
|
for ( Iterator iter = clipBoardHS.iterator(); iter.hasNext();)
|
||||||
{
|
{
|
||||||
cell = (Point)iter.next();
|
cell = (Point)iter.next();
|
||||||
clipBoard.add( new Cell(cell, this.getValueAt((int)cell.getX(), (int)cell.getY())) );
|
clipBoard.add( new Cell(cell, this.getValueAt((int)cell.getX(), (int)cell.getY())) );
|
||||||
|
|
||||||
if (cut == EnginuityJTable.CUT)
|
if (cut == EnginuityJTable.CUT)
|
||||||
{
|
{
|
||||||
setSelectionBackground(this.cutSelectionColour);
|
setSelectionBackground(this.cutSelectionColour);
|
||||||
setAction( EnginuityJTable.CUT);
|
setAction( EnginuityJTable.CUT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (cut == EnginuityJTable.COPY)
|
if (cut == EnginuityJTable.COPY)
|
||||||
{
|
{
|
||||||
setSelectionBackground(this.copySelectionColour);
|
setSelectionBackground(this.copySelectionColour);
|
||||||
setAction( EnginuityJTable.COPY);
|
setAction( EnginuityJTable.COPY);
|
||||||
|
@ -252,39 +252,39 @@ public class EnginuityJTable extends JTable
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveToClipBoard( )
|
public void moveToClipBoard( )
|
||||||
{
|
{
|
||||||
Point cell = null;
|
Point cell = null;
|
||||||
HashSet<Point> clipBoardHS = new HashSet<Point>();
|
HashSet<Point> clipBoardHS = new HashSet<Point>();
|
||||||
|
|
||||||
this.clipBoard.clear();
|
this.clipBoard.clear();
|
||||||
clipBoardHS.addAll( cellSelection );
|
clipBoardHS.addAll( cellSelection );
|
||||||
clipBoardHS.addAll( currentSelection );
|
clipBoardHS.addAll( currentSelection );
|
||||||
|
|
||||||
|
|
||||||
for ( Iterator iter = clipBoardHS.iterator(); iter.hasNext();)
|
for ( Iterator iter = clipBoardHS.iterator(); iter.hasNext();)
|
||||||
{
|
{
|
||||||
cell = (Point)iter.next();
|
cell = (Point)iter.next();
|
||||||
clipBoard.add( new Cell((int)cell.getX(), (int)cell.getY(), this.getValueAt((int)cell.getX(), (int)cell.getY())) );
|
clipBoard.add( new Cell((int)cell.getX(), (int)cell.getY(), this.getValueAt((int)cell.getX(), (int)cell.getY())) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cell with the minimum X and the Minimum Y
|
* Get the cell with the minimum X and the Minimum Y
|
||||||
* If doesn't exists this cell then the paste cannot be made
|
* If doesn't exists this cell then the paste cannot be made
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private Cell getMinCell(HashSet clipboard)
|
private Cell getMinCell(HashSet clipboard)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//sort by X Coordinate
|
//sort by X Coordinate
|
||||||
Object[] cells = clipboard.toArray();
|
Object[] cells = clipboard.toArray();
|
||||||
Arrays.sort(cells, new XComparator<Object>());
|
Arrays.sort(cells, new XComparator<Object>());
|
||||||
|
@ -293,20 +293,20 @@ public class EnginuityJTable extends JTable
|
||||||
Arrays.sort((Object[])cells, new YComparator<Object>());
|
Arrays.sort((Object[])cells, new YComparator<Object>());
|
||||||
//System.out.println("orderedByY: " + (Cell)cells[0]);
|
//System.out.println("orderedByY: " + (Cell)cells[0]);
|
||||||
Cell minY = (Cell)cells[0];
|
Cell minY = (Cell)cells[0];
|
||||||
|
|
||||||
//sort again by X coordinate
|
//sort again by X coordinate
|
||||||
Arrays.sort((Object[])cells, new XComparator<Object>());
|
Arrays.sort((Object[])cells, new XComparator<Object>());
|
||||||
Cell minX = (Cell)cells[0];
|
Cell minX = (Cell)cells[0];
|
||||||
//System.out.println("orderedByX: " + (Cell)cells[0]);
|
//System.out.println("orderedByX: " + (Cell)cells[0]);
|
||||||
|
|
||||||
if (minX.equals(minY))
|
if (minX.equals(minY))
|
||||||
return minX;
|
return minX;
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MouseMotionH implements MouseMotionListener
|
class MouseMotionH implements MouseMotionListener
|
||||||
{
|
{
|
||||||
private EnginuityJTable myJTable = null;
|
private EnginuityJTable myJTable = null;
|
||||||
|
@ -319,56 +319,56 @@ public class EnginuityJTable extends JTable
|
||||||
{
|
{
|
||||||
|
|
||||||
Point p = e.getPoint();
|
Point p = e.getPoint();
|
||||||
|
|
||||||
int row = myJTable.rowAtPoint(p);
|
int row = myJTable.rowAtPoint(p);
|
||||||
int column = myJTable.columnAtPoint(p);
|
int column = myJTable.columnAtPoint(p);
|
||||||
myJTable.changeSelection(row, column, false, true);
|
myJTable.changeSelection(row, column, false, true);
|
||||||
}
|
}
|
||||||
public void mouseMoved( MouseEvent e )
|
public void mouseMoved( MouseEvent e )
|
||||||
{
|
{
|
||||||
//System.out.println("move");
|
//System.out.println("move");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class EventKeyHandler extends KeyAdapter{
|
class EventKeyHandler extends KeyAdapter{
|
||||||
private EnginuityJTable myJTable = null;
|
private EnginuityJTable myJTable = null;
|
||||||
|
|
||||||
|
|
||||||
public EventKeyHandler(EnginuityJTable myJTable)
|
public EventKeyHandler(EnginuityJTable myJTable)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.myJTable = myJTable;
|
this.myJTable = myJTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyPressed(KeyEvent e)
|
public void keyPressed(KeyEvent e)
|
||||||
{
|
{
|
||||||
/*Copy*/
|
/*Copy*/
|
||||||
//System.out.println(e.getModifiers());
|
//System.out.println(e.getModifiers());
|
||||||
if ((e.isControlDown() && e.getKeyCode() == 67 ))
|
if ((e.isControlDown() && e.getKeyCode() == 67 ))
|
||||||
{
|
{
|
||||||
myJTable.toClipBoard(EnginuityJTable.COPY);
|
myJTable.toClipBoard(EnginuityJTable.COPY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/*Paste*/
|
/*Paste*/
|
||||||
if ((e.isControlDown() && e.getKeyCode() == 86 ))
|
if ((e.isControlDown() && e.getKeyCode() == 86 ))
|
||||||
{
|
{
|
||||||
Cell cell = getMinCell(clipBoard);
|
Cell cell = getMinCell(clipBoard);
|
||||||
Cell cutCell = null;
|
Cell cutCell = null;
|
||||||
|
|
||||||
|
|
||||||
if (cell != null)
|
if (cell != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (myJTable.getAction() == EnginuityJTable.CUT)
|
if (myJTable.getAction() == EnginuityJTable.CUT)
|
||||||
for ( Iterator iter = clipBoard.iterator(); iter.hasNext(); )
|
for ( Iterator iter = clipBoard.iterator(); iter.hasNext(); )
|
||||||
{
|
{
|
||||||
cutCell = (Cell)iter.next();
|
cutCell = (Cell)iter.next();
|
||||||
myJTable.setValueAt( null ,(int)cutCell.getX(), (int)cutCell.getY() );
|
myJTable.setValueAt( null ,(int)cutCell.getX(), (int)cutCell.getY() );
|
||||||
}
|
}
|
||||||
|
|
||||||
int deltaX, deltaY;
|
int deltaX, deltaY;
|
||||||
deltaX = lastSelectedCell.x - cell.getX();
|
deltaX = lastSelectedCell.x - cell.getX();
|
||||||
deltaY = lastSelectedCell.y - cell.getY();
|
deltaY = lastSelectedCell.y - cell.getY();
|
||||||
|
@ -384,10 +384,10 @@ public class EnginuityJTable extends JTable
|
||||||
System.err.println("Copy/Cut Selection ambigous. Could not Paste");
|
System.err.println("Copy/Cut Selection ambigous. Could not Paste");
|
||||||
// throw new Exception ("Copy/Cut Selection ambigous");
|
// throw new Exception ("Copy/Cut Selection ambigous");
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Iterator iter = clipBoard.iterator(); iter.hasNext(); )
|
for ( Iterator iter = clipBoard.iterator(); iter.hasNext(); )
|
||||||
{
|
{
|
||||||
cell = (Cell)iter.next();
|
cell = (Cell)iter.next();
|
||||||
if (cell.getX() < myJTable.getRowCount() && cell.getY() < myJTable.getColumnCount())
|
if (cell.getX() < myJTable.getRowCount() && cell.getY() < myJTable.getColumnCount())
|
||||||
myJTable.setValueAt(cell.getValue(), cell.getX(), cell.getY());
|
myJTable.setValueAt(cell.getValue(), cell.getX(), cell.getY());
|
||||||
}
|
}
|
||||||
|
@ -397,14 +397,14 @@ public class EnginuityJTable extends JTable
|
||||||
/*Cut*/
|
/*Cut*/
|
||||||
if ((e.isControlDown() && e.getKeyCode() == 88 ))
|
if ((e.isControlDown() && e.getKeyCode() == 88 ))
|
||||||
{
|
{
|
||||||
myJTable.toClipBoard(EnginuityJTable.CUT);
|
myJTable.toClipBoard(EnginuityJTable.CUT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (e.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK | InputEvent.BUTTON1_MASK ))
|
if (e.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK | InputEvent.BUTTON1_MASK ))
|
||||||
{
|
{
|
||||||
//myJTable.changeSelection(5,5,false, true);
|
//myJTable.changeSelection(5,5,false, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (e.getModifiers() == (InputEvent.SHIFT_MASK | InputEvent.BUTTON1_MASK))
|
if (e.getModifiers() == (InputEvent.SHIFT_MASK | InputEvent.BUTTON1_MASK))
|
||||||
|
@ -416,39 +416,39 @@ public class EnginuityJTable extends JTable
|
||||||
//System.out.println("SHIFT + CLICK");
|
//System.out.println("SHIFT + CLICK");
|
||||||
}else
|
}else
|
||||||
if (e.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.BUTTON1_MASK))
|
if (e.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.BUTTON1_MASK))
|
||||||
{
|
{
|
||||||
//currentSelection.clear();
|
//currentSelection.clear();
|
||||||
myJTable.changeSelection((int)myJTable.getLastSelectedCell().getX(),(int)myJTable.getLastSelectedCell().getY(),false,true);
|
myJTable.changeSelection((int)myJTable.getLastSelectedCell().getX(),(int)myJTable.getLastSelectedCell().getY(),false,true);
|
||||||
repaint();
|
repaint();
|
||||||
//System.out.println("CTRL + CLICK");
|
//System.out.println("CTRL + CLICK");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Cell
|
class Cell
|
||||||
{
|
{
|
||||||
private Object value;
|
private Object value;
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
|
|
||||||
public Cell(){};
|
public Cell(){};
|
||||||
|
|
||||||
public Cell(int x, int y, Object value)
|
public Cell(int x, int y, Object value)
|
||||||
{
|
{
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cell(Point p, Object value)
|
public Cell(Point p, Object value)
|
||||||
{
|
{
|
||||||
this.x = (int)p.getX();
|
this.x = (int)p.getX();
|
||||||
this.y = (int)p.getY();
|
this.y = (int)p.getY();
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getValue()
|
public Object getValue()
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
|
@ -472,7 +472,7 @@ public class EnginuityJTable extends JTable
|
||||||
public void setY( int y )
|
public void setY( int y )
|
||||||
{
|
{
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object o)
|
public boolean equals(Object o)
|
||||||
|
@ -480,20 +480,20 @@ public class EnginuityJTable extends JTable
|
||||||
Cell cell = null;
|
Cell cell = null;
|
||||||
if (!(o instanceof Cell))
|
if (!(o instanceof Cell))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
cell = (Cell)o;
|
cell = (Cell)o;
|
||||||
if (cell.getX()==this.x && cell.getY() == this.y)
|
if (cell.getX()==this.x && cell.getY() == this.y)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "(" + this.x + ", " + this.y + ") = " + this.value;
|
return "(" + this.x + ", " + this.y + ") = " + this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* order the Cells by the X coordinate
|
* order the Cells by the X coordinate
|
||||||
* @author fane
|
* @author fane
|
||||||
|
@ -503,9 +503,9 @@ public class EnginuityJTable extends JTable
|
||||||
{
|
{
|
||||||
|
|
||||||
public int compare(T o1, T o2) {
|
public int compare(T o1, T o2) {
|
||||||
return ((Cell)o1).getX() - ((Cell)o2).getX();
|
return ((Cell)o1).getX() - ((Cell)o2).getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -518,7 +518,7 @@ public class EnginuityJTable extends JTable
|
||||||
public int compare(T o1, T o2) {
|
public int compare(T o1, T o2) {
|
||||||
return ((Cell)o1).getY() - ((Cell)o2).getY();
|
return ((Cell)o1).getY() - ((Cell)o2).getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getCopySelectioColour() {
|
public Color getCopySelectioColour() {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package enginuity.newmaps.gui;
|
package enginuity.newmaps.swing;
|
||||||
|
|
||||||
import enginuity.newmaps.ecumetadata.AxisMetadata;
|
import enginuity.newmaps.ecumetadata.AxisMetadata;
|
||||||
import enginuity.newmaps.ecumetadata.Scale;
|
import enginuity.newmaps.ecumetadata.Scale;
|
||||||
|
@ -28,19 +28,19 @@ import enginuity.newmaps.ecumetadata.Table3DMetadata;
|
||||||
import enginuity.newmaps.ecumetadata.Unit;
|
import enginuity.newmaps.ecumetadata.Unit;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
|
|
||||||
public class Frame3D extends EnginuityFrame {
|
public class Frame3D extends EnginuityFrame {
|
||||||
|
|
||||||
EnginuityJTable xAxisTable;
|
EnginuityJTable xAxisTable;
|
||||||
EnginuityJTable yAxisTable;
|
EnginuityJTable yAxisTable;
|
||||||
EnginuityJTable table;
|
EnginuityJTable table;
|
||||||
|
|
||||||
public Frame3D(byte[] data, Table3DMetadata metadata) {
|
public Frame3D(byte[] data, Table3DMetadata metadata) {
|
||||||
|
|
||||||
super(data, (TableMetadata)metadata);
|
super(data, (TableMetadata)metadata);
|
||||||
|
|
||||||
table = new EnginuityJTable(5, 5);
|
table = new EnginuityJTable(5, 5);
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
for (int j = 0; j < 5; j++)
|
for (int j = 0; j < 5; j++)
|
||||||
{
|
{
|
||||||
|
@ -48,33 +48,33 @@ public class Frame3D extends EnginuityFrame {
|
||||||
}
|
}
|
||||||
JScrollPane scrollPane = new JScrollPane( table );
|
JScrollPane scrollPane = new JScrollPane( table );
|
||||||
getContentPane().add( scrollPane );
|
getContentPane().add( scrollPane );
|
||||||
|
|
||||||
this.pack();
|
this.pack();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void populateTable(byte[] data) {
|
private void populateTable(byte[] data) {
|
||||||
//
|
//
|
||||||
// Do table first..
|
// Do table first..
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Test driver
|
// Test driver
|
||||||
//
|
//
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
byte[] data = new byte[100];
|
byte[] data = new byte[100];
|
||||||
for (int i = 0; i < data.length; i++) {
|
for (int i = 0; i < data.length; i++) {
|
||||||
data[i] = (byte)i;
|
data[i] = (byte)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create table and axis
|
// Create table and axis
|
||||||
//
|
//
|
||||||
|
@ -91,16 +91,16 @@ public class Frame3D extends EnginuityFrame {
|
||||||
yAxis.setAddress(25);
|
yAxis.setAddress(25);
|
||||||
yAxis.setSize(5);
|
yAxis.setSize(5);
|
||||||
table.setYaxis(yAxis);
|
table.setYaxis(yAxis);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create scales
|
// Create scales
|
||||||
//
|
//
|
||||||
Unit tableUnit = new Unit("Table Unit");
|
Unit tableUnit = new Unit("Table Unit");
|
||||||
tableUnit.setCoarseIncrement(2);
|
tableUnit.setCoarseIncrement(2);
|
||||||
tableUnit.setFineIncrement(1);
|
tableUnit.setFineIncrement(1);
|
||||||
tableUnit.setFormat("0.0");
|
tableUnit.setFormat("0.0");
|
||||||
tableUnit.setTo_byte("x / 2");
|
tableUnit.setTo_byte("x / 2");
|
||||||
tableUnit.setTo_real("x * 2");
|
tableUnit.setTo_real("x * 2");
|
||||||
Scale tableScale = new Scale("Table Scale");
|
Scale tableScale = new Scale("Table Scale");
|
||||||
Unit[] tableUnits = {tableUnit};
|
Unit[] tableUnits = {tableUnit};
|
||||||
tableScale.setUnits(tableUnits);
|
tableScale.setUnits(tableUnits);
|
||||||
|
@ -108,13 +108,13 @@ public class Frame3D extends EnginuityFrame {
|
||||||
tableScale.setEndian(Scale.ENDIAN_BIG);
|
tableScale.setEndian(Scale.ENDIAN_BIG);
|
||||||
tableScale.setStorageType(Scale.STORAGE_TYPE_UINT16);
|
tableScale.setStorageType(Scale.STORAGE_TYPE_UINT16);
|
||||||
table.setScale(tableScale);
|
table.setScale(tableScale);
|
||||||
|
|
||||||
Unit xUnit = new Unit("X Unit");
|
Unit xUnit = new Unit("X Unit");
|
||||||
xUnit.setCoarseIncrement(2);
|
xUnit.setCoarseIncrement(2);
|
||||||
xUnit.setFineIncrement(1);
|
xUnit.setFineIncrement(1);
|
||||||
xUnit.setFormat("0.0");
|
xUnit.setFormat("0.0");
|
||||||
xUnit.setTo_byte("x / 2");
|
xUnit.setTo_byte("x / 2");
|
||||||
xUnit.setTo_real("x * 2");
|
xUnit.setTo_real("x * 2");
|
||||||
Scale xScale = new Scale("X Scale");
|
Scale xScale = new Scale("X Scale");
|
||||||
Unit[] xUnits = {xUnit};
|
Unit[] xUnits = {xUnit};
|
||||||
xScale.setUnits(xUnits);
|
xScale.setUnits(xUnits);
|
||||||
|
@ -122,22 +122,22 @@ public class Frame3D extends EnginuityFrame {
|
||||||
xScale.setEndian(Scale.ENDIAN_LITTLE);
|
xScale.setEndian(Scale.ENDIAN_LITTLE);
|
||||||
xScale.setStorageType(Scale.STORAGE_TYPE_INT8);
|
xScale.setStorageType(Scale.STORAGE_TYPE_INT8);
|
||||||
xAxis.setScale(xScale);
|
xAxis.setScale(xScale);
|
||||||
|
|
||||||
Unit yUnit = new Unit("Y Unit");
|
Unit yUnit = new Unit("Y Unit");
|
||||||
yUnit.setCoarseIncrement(3);
|
yUnit.setCoarseIncrement(3);
|
||||||
yUnit.setFineIncrement(2);
|
yUnit.setFineIncrement(2);
|
||||||
yUnit.setFormat("0.00");
|
yUnit.setFormat("0.00");
|
||||||
yUnit.setTo_byte("x * 2");
|
yUnit.setTo_byte("x * 2");
|
||||||
yUnit.setTo_real("x / 2");
|
yUnit.setTo_real("x / 2");
|
||||||
Scale yScale = new Scale("Y Scale");
|
Scale yScale = new Scale("Y Scale");
|
||||||
Unit[] yUnits = {yUnit};
|
Unit[] yUnits = {yUnit};
|
||||||
yScale.setUnits(yUnits);
|
yScale.setUnits(yUnits);
|
||||||
yScale.setDescription("This is the y scale");
|
yScale.setDescription("This is the y scale");
|
||||||
yScale.setEndian(Scale.ENDIAN_LITTLE);
|
yScale.setEndian(Scale.ENDIAN_LITTLE);
|
||||||
yScale.setStorageType(Scale.STORAGE_TYPE_FLOAT);
|
yScale.setStorageType(Scale.STORAGE_TYPE_FLOAT);
|
||||||
yAxis.setScale(yScale);
|
yAxis.setScale(yScale);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create frame
|
// Create frame
|
||||||
//
|
//
|
||||||
|
@ -146,7 +146,7 @@ public class Frame3D extends EnginuityFrame {
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setLocationRelativeTo( null );
|
frame.setLocationRelativeTo( null );
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package enginuity.newmaps.gui;
|
package enginuity.newmaps.swing;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import javax.swing.DefaultListSelectionModel;
|
import javax.swing.DefaultListSelectionModel;
|
||||||
|
@ -33,11 +33,11 @@ import javax.swing.DefaultListSelectionModel;
|
||||||
*/
|
*/
|
||||||
public class TableSelectionModel extends DefaultListSelectionModel
|
public class TableSelectionModel extends DefaultListSelectionModel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final int MULTIPLE_SELECTION = 3;
|
public static final int MULTIPLE_SELECTION = 3;
|
||||||
|
|
||||||
private int selectionMode = MULTIPLE_INTERVAL_SELECTION;
|
private int selectionMode = MULTIPLE_INTERVAL_SELECTION;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package enginuity.newmaps.gui;
|
package enginuity.newmaps.swing;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
|
Loading…
Reference in New Issue