public void mouseDragged(MouseEvent e) { if (matrixGUIObject.getRowSelectionModel().getValueIsAdjusting()) { long newRow = getRowPos(e.getY()); long newCol = getColPos(e.getX()); newRow = newRow < 0 ? 0 : newRow; newCol = newCol < 0 ? 0 : newCol; newRow = newRow >= matrixGUIObject.getRowCount() ? matrixGUIObject.getRowCount() - 1 : newRow; newCol = newCol >= matrixGUIObject.getColumnCount() ? matrixGUIObject.getColumnCount() - 1 : newCol; matrixGUIObject.getRowSelectionModel().setSelectionInterval(startRow, newRow); matrixGUIObject.getColumnSelectionModel().setSelectionInterval(startCol, newCol); repaint(100); } }
public void actionPerformed(ActionEvent e) { try { Matlab.getInstance().plot(matrix.getMatrix()); } catch (Exception e1) { e1.printStackTrace(); } } }
public MatrixStatisticsBar(MatrixGUIObject m) { this.matrixGUIObject = m; m.addTableModelListener(this); m.getRowSelectionModel().addListSelectionListener(this); m.getColumnSelectionModel().addListSelectionListener(this); update(); }
public String getToolTipText(MouseEvent e) { // only generate tool text when a matrix with size >0 is available if (matrixGUIObject.getRowCount() > 0 && matrixGUIObject.getColumnCount() > 0) { long r = getRowPos(e.getY()); long c = getColPos(e.getX()); r = r < 0 ? 0 : r; c = c < 0 ? 0 : c; r = r >= matrixGUIObject.getRowCount() ? matrixGUIObject.getRowCount() - 1 : r; c = c >= matrixGUIObject.getColumnCount() ? matrixGUIObject.getColumnCount() - 1 : c; String toolTip = TooltipUtil.getTooltip(matrixGUIObject, r, c); return toolTip; } else { return null; } }
long totalColumn = matrixGUIObject.getColumnCount(); long totalRows = matrixGUIObject.getRowCount(); g2d.addRenderingHints(UIDefaults.AALIAS); String s = ""; if (matrixGUIObject.getLabel() != null) { s += "[" + matrixGUIObject.getLabel() + "]"; } else { s += matrixGUIObject.getMatrix().getClass().getSimpleName(); final long mx = (long) Math.floor(x * stepsizeX); final long my = (long) Math.floor(y * stepsizeY); final Color col = matrixGUIObject.getColorAt(my, mx); if (col != null) { pixels[pos++] = (col.getRed() << 16) + (col.getGreen() << 8) + col.getBlue(); final long rowCount = matrixGUIObject.getRowCount(); final long colCount = matrixGUIObject.getColumnCount(); for (int row = 0; row < rowCount; row++) { for (int col = 0; col < colCount; col++) { final Color color = matrixGUIObject.getColorAt(row, col); final int pos = getPosition(totalColumn, row, col); if (color != null) { if (width > 20 && matrixGUIObject.getRowCount() == 1 && matrixGUIObject.getColumnCount() == 1) { final Color col = matrixGUIObject.getColorAt(0, 0); g2d.setColor(ColorUtil.contrastBW(col)); String s = UJMPFormat.getSingleLineInstance().format(matrixGUIObject.getValueAt(0, 0)); if (s != null && s.length() > 25) {
String title = getMatrix().getLabel(); String xLabel = StringUtil.format(getMatrix().getMatrix().getDimensionLabel(Matrix.ROW)); String yLabel = null; for (int i = 0; i < getMatrix().getColumnCount(); i++) { renderer.setSeriesStroke(i, new BasicStroke(3)); plot.setRenderer(i, renderer);
public MatrixPanel(MatrixGUIObject m) { super(m); if (!(m instanceof DefaultMatrixGUIObject)) { m = new DefaultMatrixGUIObject(m.getMatrix()); MapMatrix<String, Object> metaData = m.getMatrix().getMetaData(); if (metaData != null) { splitPane2.setTopComponent(new MatrixEditorPanel("Meta Data", (MatrixGUIObject) m.getMatrix().getMetaData() .getGUIObject())); if (m.getMatrix() instanceof GraphMatrix && m.getColumnCount() < 1000) { tabbedPane.add("Graph", new GraphPanel(m)); tabbedPane.setSelectedIndex(tabbedPane.getComponentCount() - 1); if (m.getMatrix() instanceof GraphMatrix && ((GraphMatrix<?, ?>) m.getMatrix()).getNodeCount() < 1000) { try { Class<?> graphPanelClass = Class.forName("org.ujmp.jung.JungVisualizationViewer"); Constructor<?> graphPanelConstructor = graphPanelClass.getConstructor(GraphMatrix.class); JPanel graphPanel = (JPanel) graphPanelConstructor.newInstance(m.getMatrix()); tabbedPane.add("JUNG Graph", graphPanel); tabbedPane.setSelectedIndex(tabbedPane.getComponentCount() - 1); if (m.getMatrix() instanceof TreeModel) { tabbedPane.add("Tree", new MatrixTreePanel(m)); if (m.getMatrix() instanceof TreeMatrix) { tabbedPane.add("Treemap", new MatrixTreemapPanel((TreeMatrix<?>) m.getMatrix())); if (m.getRowCount() > 1) { try {
hasFocus, row, column); case MatrixListTableModel.SIZECOLUMN: o = "" + matrix.getColumnCount() + "x" + matrix.getRowCount(); break; case MatrixListTableModel.LABELCOLUMN: o = StringUtil.format(matrix.getLabel()); break; default:
private static boolean paintMatrixOriginal(Graphics g, MatrixGUIObject matrix, int width, int height) { boolean wasAllDataLoaded = true; try { long cols = matrix.getColumnCount(); long rows = matrix.getRowCount(); bg.setColor(matrix.getColorAt(row, col)); bg.fillRect((int) (col / xStepSize), (int) (row / yStepSize), 1, 1); if (wasAllDataLoaded && matrix.getValueAt(row, col) == MatrixGUIObject.PRELOADER) { wasAllDataLoaded = false; if (width > 20 && matrix.getRowCount() == 1 && matrix.getColumnCount() == 1) { String s = UJMPFormat.getSingleLineInstance().format(matrix.getValueAt(0, 0)); if (s != null && s.length() > 25) { s = s.substring(0, 25) + "...";
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.addRenderingHints(UIDefaults.AALIAS); MatrixGUIObject m = (MatrixGUIObject) getGUIObject(); final int totalCount = m.getColumnCount(); Color color = new Color(0, 0, 200, 128); final int size = getCircleSize(totalCount); final int xCount = getSize().width / size; for (int index = 0; index < totalCount; index++) { g2d.setColor(color); g2d.fillOval(size * (index % xCount), size * (index / xCount), size / 2, size / 2); } for (long[] c : m.getMatrix().availableCoordinates()) { g2d.setColor(color); g2d.drawLine((int) (size * (c[0] % xCount)), (int) (size * (c[0] / xCount)), (int) (size * (c[1] % xCount)), (int) (size * (c[1] / xCount))); } }
public MatrixGUIObject getMatrixObject() { MatrixGUIObject m = (MatrixGUIObject) getGUIObject(); if (m != null) { int startRow = m.getRowSelectionModel().getMinSelectionIndex(); int endRow = m.getRowSelectionModel().getMaxSelectionIndex(); int startColumn = m.getColumnSelectionModel().getMinSelectionIndex(); int endColumn = m.getColumnSelectionModel().getMaxSelectionIndex(); if (startRow != -1 && startColumn != -1) { m = (MatrixGUIObject) m.getMatrix().subMatrix(Ret.LINK, startRow, startColumn, endRow, endColumn) .getGUIObject(); } return m; } else { // int min = variable.getRowSelectionModel().getMinSelectionIndex(); // int max = variable.getRowSelectionModel().getMaxSelectionIndex(); // Matrix all = new MatrixListToMatrixWrapper(variable); // // if (min >= 0 && max >= 0) { // Matrix selection = all.subMatrix(Ret.LINK, min, 0, max, // all.getColumnCount() - 1); // return (MatrixGUIObject) selection.getGUIObject(); // } else { // return (MatrixGUIObject) all.getGUIObject(); // } } return null; }
public void mouseClicked(MouseEvent e) { long newRow = getRowPos(e.getY()); long newCol = getColPos(e.getX()); if (e.getButton() == MouseEvent.BUTTON3) { newRow = newRow < 0 ? 0 : newRow; newCol = newCol < 0 ? 0 : newCol; newRow = newRow >= matrixGUIObject.getRowCount() ? matrixGUIObject.getRowCount() - 1 : newRow; newCol = newCol >= matrixGUIObject.getColumnCount() ? matrixGUIObject.getColumnCount() - 1 : newCol; JPopupMenu popup = new MatrixPopupMenu(this, matrixGUIObject, newRow, newCol); popup.show(this, e.getX(), e.getY()); } else if (e.getButton() == MouseEvent.BUTTON1) { // left click: show new window if value is a matrix Object o = matrixGUIObject.getValueAt(newRow, newCol); if (o instanceof Matrix) { ((Matrix) o).showGUI(); } } }
public void graphClicked(N v, MouseEvent me) { long index = graphMatrix.getIndexOfNode(v); matrixGUIObject.getRowSelectionModel().setSelectionInterval(index, index); matrixGUIObject.getColumnSelectionModel().setSelectionInterval(index, index); }
public void keyPressed(KeyEvent e) { long rows = matrixGUIObject.getRowCount64(); long cols = matrixGUIObject.getColumnCount64(); long minRow = matrixGUIObject.getRowSelectionModel().getMinSelectionIndex64(); long maxRow = matrixGUIObject.getRowSelectionModel().getMaxSelectionIndex64(); long minCol = matrixGUIObject.getColumnSelectionModel().getMinSelectionIndex64(); long maxCol = matrixGUIObject.getColumnSelectionModel().getMaxSelectionIndex64(); if ((e.getKeyCode() == KeyEvent.VK_A) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { matrixGUIObject.getColumnSelectionModel().setSelectionInterval(0, cols - 1); matrixGUIObject.getRowSelectionModel().setSelectionInterval(0, rows - 1); } else if (e.getKeyCode() == KeyEvent.VK_UP && minRow > 0) { matrixGUIObject.getRowSelectionModel().setSelectionInterval(minRow - 1, maxRow - 1); } else if (e.getKeyCode() == KeyEvent.VK_DOWN && maxRow < rows - 1) { matrixGUIObject.getRowSelectionModel().setSelectionInterval(minRow + 1, maxRow + 1); } else if (e.getKeyCode() == KeyEvent.VK_LEFT && minCol > 0) { matrixGUIObject.getColumnSelectionModel().setSelectionInterval(minCol - 1, maxCol - 1); } else if (e.getKeyCode() == KeyEvent.VK_RIGHT && maxCol < cols - 1) { matrixGUIObject.getColumnSelectionModel().setSelectionInterval(minCol + 1, maxCol + 1); } }
public void run() { StringBuilder s = new StringBuilder(); if (guiObject instanceof MatrixGUIObject) { MatrixGUIObject matrix = ((MatrixGUIObject) guiObject); long[] c = matrix.getMouseOverCoordinates(); s.append("Position: "); s.append(Coordinates.toString(c)); if (!matrix.getRowSelectionModel().isSelectionEmpty() || !matrix.getColumnSelectionModel().isSelectionEmpty()) { long y0 = matrix.getRowSelectionModel().getMinSelectionIndex64(); long y1 = matrix.getRowSelectionModel().getMaxSelectionIndex64(); long x0 = matrix.getColumnSelectionModel().getMinSelectionIndex64(); long x1 = matrix.getColumnSelectionModel().getMaxSelectionIndex64(); long xSize = 1 + Math.abs(x1 - x0); long ySize = 1 + Math.abs(y1 - y0); s.append(" Selection: [" + y0 + "," + x0 + "] - [" + y1 + "," + x1 + "] = "); s.append("[" + ySize + "x" + xSize + "]"); } setStatusString(s.toString()); } statusBar.setProgress(TaskQueue.getProgress()); } }
public int getItemCount() { return (int) matrix.getRowCount(); }
double yf = plotSettings.getYFactor(); for (int t = 0; t < Math.min(10, plotSettings.getMatrixGUIObject().getColumnCount()); t++) { Object o1 = plotSettings.getMatrixGUIObject().getValueAt((int) row1, (int) column); if (o1 instanceof Matrix) { yv1 = Double.NaN; Object o2 = plotSettings.getMatrixGUIObject().getValueAt((int) row2, (int) column); if (o2 instanceof Matrix) { yv2 = Double.NaN;
public XYSeriesCollectionWrapper(MatrixGUIObject m) { this.matrix = m; int size = (int) Math.min(m.getColumnCount(), maxSeriesCount); for (int i = 0; i < size; i++) { addSeries(new XYSeriesWrapper(matrix, i)); } }
columnLabel = matrix.getColumnName(coordinates[Matrix.COLUMN]); } catch (Exception e) { o = matrix.getValueAt(coordinates[0], coordinates[1]); } catch (Exception e) {
public XYSeriesWrapper(MatrixGUIObject m, int number) { super(m.getColumnName(number), false, true); this.seriesId = number; this.matrix = m; // meanMarker = new MeanMarkerForVariable(variable, number); // standardDeviationMarker = new // StandardDeviationMarkerForVariable(variable, number); // minMaxMarker = new MinMaxMarkerForVariable(variable, number); // variable.getVariable().addVariableListener(this); // stepsize = (int) Math.ceil((double) // variable.getVariable().getMatrixCount() / (double) MAXITEMS); }