Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.nuiton.math.matrix.gui.MatrixPanelEditor Maven / Gradle / Ivy
package org.nuiton.math.matrix.gui;
import org.nuiton.math.matrix.gui.*;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.io.*;
import java.lang.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import jaxx.runtime.swing.JAXXButtonGroup;
import jaxx.runtime.swing.HBox;
import jaxx.runtime.swing.VBox;
import jaxx.runtime.swing.Table;
import static org.nuiton.i18n.I18n._;
import static jaxx.runtime.Util.createImageIcon;
import jaxx.runtime.SwingUtil;
import static jaxx.runtime.Util.getStringValue;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.Collection;
import java.util.HashSet;
import org.nuiton.math.matrix.MatrixFactory;
import org.nuiton.math.matrix.MatrixND;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class MatrixPanelEditor extends org.nuiton.math.matrix.gui.MatrixEditor implements jaxx.runtime.JAXXObject {
public static final Log log = LogFactory.getLog(org.nuiton.math.matrix.gui.MatrixPanelEditor.class);
private static java.lang.String $jaxxObjectDescriptor = "H4sIAAAAAAAAAK1Uz08TQRR+rbRAaxEQ0YNEUG6YrUKMiRCUHxIhrRrwQOzFaXdsh0x31plZWDwYE6/GcPLgRb179G6MR09e/R+M8T/wzey2W7ACifaw2773vW++9+Z9/fADMkrCxBYJQ0cGnmZN6qwtbG7eq27Rml6mqiaZr4WE6JNKQ7oCebcdVxouVUqmvBiXF5dE0xce9TqqZ0uQU3qXU9WgVGs4E1XUlCputMOzoR/IFltbTDe2d79+pvfc5+/TAKGPqvLYwvhRVUkHPSVIM1fDMJ60TYqceHWUIZlXR50FE1viRKm7pEmfwDPoLUHWJxLJNFw8fquWw9aHvoaByTLBI8LbLkPQFQ2Xhaw7XoC/PKdJdMM8MO/UA+ZE0PvEozzC+75lymrIaVLltCxcyjVMHcnxoI1OKPKceZTImGPI9OuYGTiLQnBKvAQ52oHcaIidZfqYBFyb7FCCKrg4Ck8x4RmxB5KnJzfsYFY9phnh7CmVVzVcsJdVw+kxTqXzB+TQ+mmTOncoZOYApI+isgVJiYazpt/QUTt43c4aVgrOzaQNsr9dkLFjxhXZh7bTNIix5D6qgdZR56hkH3rRZmJeaZKmZ6WcZOWTnUxVICMDDGsYrCTuWMdQ5Is4agls9O2LN9uvP3660TJBFs8o7IN0eBaX0pfCp1Izc8SpaPMDzXixTPzZCvQrytHw1tAjHQI24jCKQP5oWUyZc4eoBpZmer9//jL66NsJSK9AjgvirhCDX4V+3ZDYpeBu6N+8ZZWc3OnD56DRpCHLya7AEcHAnEs0Ga8yz8W5zYfY7EhHs20FX/dels+/GrveajgVCToAS5rOPIQs88wKW7/HVu7q77yvaOCKxLLdTJwy75wfb9WUfRa7dTZAAi3WqcJNNNYxuOkwMK8ZK9t8u2bZJo7BNlKjnEfdGYt5Zgfdf+QsqBbffxDYo2mI1zg8Fw17nGj850Fb0PnunJPH4OzdZorFZvuLNEPzG/i6AEC/BgAA";
protected java.util.List $activeBindings = new ArrayList();
protected java.util.Map $bindingSources = new HashMap();
protected Map $objectMap = new HashMap();
protected javax.swing.JButton buttonEdit;
protected final jaxx.runtime.JAXXContext delegateContext = new jaxx.runtime.DefaultJAXXContext(this);;
protected java.lang.Boolean dimensionEdit;
protected javax.swing.JScrollPane editArea;
protected java.lang.Boolean linearModel;
protected java.lang.Boolean linearModelShowDefault;
protected javax.swing.JTable table;
protected org.nuiton.math.matrix.gui.MatrixTableModel tableModel;
private org.nuiton.math.matrix.gui.MatrixPanelEditor $MatrixEditor0 = this;
private boolean allComponentsCreated;
private boolean contextInitialized = true;
java.util.Map $previousValues = new java.util.HashMap();
private java.beans.PropertyChangeListener $DataSource8 = new jaxx.runtime.DataBindingListener($MatrixEditor0, "buttonEdit.visible");
/* begin raw body code */
private final static int DEFAULT_WIDTH = 150;
private final static int DEFAULT_HEIGHT = 150;
protected Collection matrixPanelListeners;
protected MatrixPopupMenu popupMenu;
protected MatrixND matrix;
public MatrixPanelEditor(MatrixND m, boolean dimensionEdit) {
this(dimensionEdit, DEFAULT_WIDTH, DEFAULT_HEIGHT);
jaxx.runtime.Util.assignment(matrix = m, "matrix", org.nuiton.math.matrix.gui.MatrixPanelEditor.this);
}
public MatrixPanelEditor(boolean dimensionEdit, int width, int height) {
this.dimensionEdit = dimensionEdit;
setPreferredSize(new Dimension(width, height));
$initialize();
}
public MatrixPanelEditor(boolean dimensionEdit) {
this(dimensionEdit, DEFAULT_WIDTH, DEFAULT_HEIGHT);
}
public void setMatrix(MatrixND m){
this.matrix = m;
initObject();
}
public MatrixND getMatrix() {
return matrix;
}
protected MatrixFactory getFactory() {
return MatrixFactory.getInstance();
}
public void addMatrixPanelListener(MatrixPanelListener l) {
matrixPanelListeners.add(l);
}
public void removeMatrixPanelListener(MatrixPanelListener l) {
matrixPanelListeners.remove(l);
}
protected void initObject() {
if (getMatrix() == null) {
editArea.setViewportView(null);
}
else {
jaxx.runtime.Util.assignment(popupMenu = new MatrixPopupMenu(this), "popupMenu", org.nuiton.math.matrix.gui.MatrixPanelEditor.this);
table = new JTable() {
public void processMouseEvent(MouseEvent event) {
if (event.isPopupTrigger()) {
popupMenu.show(event.getComponent(), event.getX(), event.getY());
}
super.processMouseEvent(event);
}
};
table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK),"copy");
table.getActionMap().put("copy",popupMenu.getSendToClipBoardSelectionCopyAction());
table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK),"paste");
table.getActionMap().put("paste",popupMenu.getSendToClipBoardCurrentPasteAction());
if (isLinearModel()) {
setTableModel(new MatrixTableModelLinear(getMatrix(), isLinearModelShowDefault()));
}
else {
setTableModel(new MatrixTableModelND(getMatrix()));
}
getTableModel().addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
fireEvent();
}
});
table.setModel(getTableModel());
table.setDefaultRenderer(String.class, tableModel.getMatrixCellRenderer());
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
editArea.setViewportView(table);
}
repaint();
}
protected void btnAction() {
String dim;
dim = JOptionPane.showInputDialog(null, _("nuitonmatrix.create.matrix.message"), _("nuitonmatrix.create.matrix.title"), JOptionPane.DEFAULT_OPTION);
if (dim != null) {
String[] sdim = dim.split(";");
int[] idim = new int[sdim.length];
for (int i = 0; i < idim.length; i++) {
idim[i] = Integer.parseInt(sdim[i]);
}
setMatrix(getFactory().create(idim));
}
}
protected void fireEvent() {
MatrixPanelEvent e = new MatrixPanelEvent(this);
for (MatrixPanelListener matrixPanelListener : matrixPanelListeners) {
matrixPanelListener.matrixChanged(e);
}
}
/* end raw body code */
/*---------------------------------------------------------------------------------*/
/*-- Statics methods --------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
public static jaxx.runtime.JAXXObjectDescriptor $getJAXXObjectDescriptor() {
return jaxx.runtime.Util.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
}
/*---------------------------------------------------------------------------------*/
/*-- Constructors -----------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
public MatrixPanelEditor() {
$initialize();
}
public MatrixPanelEditor(jaxx.runtime.JAXXContext parentContext) {
if (parentContext instanceof jaxx.runtime.JAXXInitialContext) {
((jaxx.runtime.JAXXInitialContext)parentContext).to(this);
} else {
setContextValue(parentContext);
}
$initialize();
}
/*---------------------------------------------------------------------------------*/
/*-- JAXXObject implementation ----------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
public void applyDataBinding(String $binding) {
if ("buttonEdit.visible".equals($binding)) {
addPropertyChangeListener("dimensionEdit", $DataSource8);
}
processDataBinding($binding);
}
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
super.firePropertyChange(propertyName, oldValue, newValue);
}
public Map get$objectMap() {
return $objectMap;
}
public java.lang.Object getObjectById(String id) {
return $objectMap.get(id);
}
public void processDataBinding(String dest) {
processDataBinding(dest, false);
}
public void processDataBinding(String $dest, boolean $force) {
if (!$force && $activeBindings.contains($dest)) {
return;
}
$activeBindings.add($dest);
try {
if ("buttonEdit.visible".equals($dest)) {
buttonEdit.setVisible((isDimensionEdit()));
}} finally {
$activeBindings.remove($dest);
}
}
public void removeDataBinding(String $binding) {
if ("buttonEdit.visible".equals($binding)) {
removePropertyChangeListener("dimensionEdit", $DataSource8);
}
}
/*---------------------------------------------------------------------------------*/
/*-- JAXXContext implementation ---------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
public T getContextValue(Class clazz) {
return delegateContext.getContextValue(clazz, null);
}
public T getContextValue(Class clazz, String name) {
return delegateContext.getContextValue(clazz, name);
}
public jaxx.runtime.JAXXContext getDelegateContext() {
return delegateContext;
}
public O getParentContainer(Class clazz) {
return delegateContext.getParentContainer(clazz);
}
public O getParentContainer(Object source, Class clazz) {
return delegateContext.getParentContainer(source, clazz);
}
public void removeContextValue(Class clazz) {
delegateContext.removeContextValue(clazz, null);
}
public void removeContextValue(Class clazz, String name) {
delegateContext.removeContextValue(clazz, name);
}
public void setContextValue(T o) {
delegateContext.setContextValue(o, null);
}
public void setContextValue(T o, String name) {
delegateContext.setContextValue(o, name);
}
/*---------------------------------------------------------------------------------*/
/*-- Event methods ----------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
public void doActionPerformed__on__buttonEdit(java.awt.event.ActionEvent event) {
btnAction();
}
/*---------------------------------------------------------------------------------*/
/*-- public acessor methods -------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
public java.util.List get$activeBindings() {
return $activeBindings;
}
public java.util.Map get$bindingSources() {
return $bindingSources;
}
public javax.swing.JButton getButtonEdit() {
return buttonEdit;
}
public java.lang.Boolean getDimensionEdit() {
return dimensionEdit;
}
public javax.swing.JScrollPane getEditArea() {
return editArea;
}
public java.lang.Boolean getLinearModel() {
return linearModel;
}
public java.lang.Boolean getLinearModelShowDefault() {
return linearModelShowDefault;
}
public javax.swing.JTable getTable() {
return table;
}
public org.nuiton.math.matrix.gui.MatrixTableModel getTableModel() {
return tableModel;
}
public java.lang.Boolean isDimensionEdit() {
return dimensionEdit !=null && dimensionEdit;
}
public java.lang.Boolean isLinearModel() {
return linearModel !=null && linearModel;
}
public java.lang.Boolean isLinearModelShowDefault() {
return linearModelShowDefault !=null && linearModelShowDefault;
}
/*---------------------------------------------------------------------------------*/
/*-- public mutator methods -------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
public void setDimensionEdit(java.lang.Boolean newValue) {
java.lang.Boolean oldValue = this.dimensionEdit;
this.dimensionEdit = newValue;
firePropertyChange("dimensionEdit", oldValue, newValue);
}
public void setLinearModel(java.lang.Boolean newValue) {
java.lang.Boolean oldValue = this.linearModel;
this.linearModel = newValue;
firePropertyChange("linearModel", oldValue, newValue);
}
public void setLinearModelShowDefault(java.lang.Boolean newValue) {
java.lang.Boolean oldValue = this.linearModelShowDefault;
this.linearModelShowDefault = newValue;
firePropertyChange("linearModelShowDefault", oldValue, newValue);
}
public void setTableModel(org.nuiton.math.matrix.gui.MatrixTableModel newValue) {
org.nuiton.math.matrix.gui.MatrixTableModel oldValue = this.tableModel;
this.tableModel = newValue;
firePropertyChange("tableModel", oldValue, newValue);
}
/*---------------------------------------------------------------------------------*/
/*-- protected acessors methods ---------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
protected org.nuiton.math.matrix.gui.MatrixPanelEditor get$MatrixEditor0() {
return $MatrixEditor0;
}
protected java.lang.String get$jaxxObjectDescriptor() {
return $jaxxObjectDescriptor;
}
protected java.util.Map get$previousValues() {
return $previousValues;
}
protected boolean getAllComponentsCreated() {
return allComponentsCreated;
}
protected boolean getContextInitialized() {
return contextInitialized;
}
protected Log getLog() {
return log;
}
/*---------------------------------------------------------------------------------*/
/*-- ui creation methods ----------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
private void $completeSetup() {
allComponentsCreated = true;
$MatrixEditor0.add(editArea, BorderLayout.CENTER);
$MatrixEditor0.add(buttonEdit, BorderLayout.SOUTH);
addChildrenToEditArea();
table.setAutoResizeMode((JTable.AUTO_RESIZE_OFF));
table.setCellSelectionEnabled((true));
table.setSelectionMode((ListSelectionModel.SINGLE_INTERVAL_SELECTION));
applyDataBinding("buttonEdit.visible");
}
private void $initialize() {
if (allComponentsCreated || !contextInitialized) {
return;
}
$objectMap.put("$MatrixEditor0", this);
createTableModel();
createLinearModel();
createLinearModelShowDefault();
createDimensionEdit();
matrixPanelListeners = new HashSet();
popupMenu = null;
matrix = null;
createEditArea();
createTable();
createButtonEdit();
$MatrixEditor0.setName("$MatrixEditor0");
$MatrixEditor0.setLayout((new BorderLayout()));
initObject();
$completeSetup();
}
protected void addChildrenToEditArea() {
if (!allComponentsCreated) {
return;
}
editArea.getViewport().add(table);
}
protected void createButtonEdit() {
buttonEdit = new javax.swing.JButton();
$objectMap.put("buttonEdit", buttonEdit);
buttonEdit.setName("buttonEdit");
buttonEdit.setText(_("nuitonmatrix.create.matrix.button"));
buttonEdit.addActionListener((java.awt.event.ActionListener) jaxx.runtime.Util.getEventListener(java.awt.event.ActionListener.class, "actionPerformed", $MatrixEditor0, "doActionPerformed__on__buttonEdit"));
}
protected void createDimensionEdit() {
dimensionEdit = false;
$objectMap.put("dimensionEdit", dimensionEdit);
}
protected void createEditArea() {
editArea = new javax.swing.JScrollPane();
$objectMap.put("editArea", editArea);
editArea.setName("editArea");
}
protected void createLinearModel() {
linearModel = false;
$objectMap.put("linearModel", linearModel);
}
protected void createLinearModelShowDefault() {
linearModelShowDefault = false;
$objectMap.put("linearModelShowDefault", linearModelShowDefault);
}
protected void createTable() {
table = new javax.swing.JTable();
$objectMap.put("table", table);
table.setName("table");
}
protected void createTableModel() {
tableModel = null;
$objectMap.put("tableModel", tableModel);
}
}