/** * Constructs a new color bar with specified label. * @param label the label; null, if none. */ public ColorBar(String label) { super(); _mosaic = new Mosaic(1,1,EnumSet.of(Mosaic.AxesPlacement.RIGHT)); if (label!=null) _mosaic.getTileAxisRight(0).setLabel(label); _mosaic.setWidthMinimum(0,15); _mosaic.setWidthElastic(0,0); _tile = _mosaic.getTile(0,0); this.setLayout(new BorderLayout()); this.add(_mosaic,BorderLayout.CENTER); }
/** * Sets the format for the horizontal axis in the specified column. * @param icol the column index. * @param format the format. */ public void setHFormat(int icol, String format) { if (_axesPlacement==AxesPlacement.LEFT_TOP) { _mosaic.getTileAxisTop(icol).setFormat(format); } else if (_axesPlacement==AxesPlacement.LEFT_BOTTOM) { _mosaic.getTileAxisBottom(icol).setFormat(format); } }
TileAxis[] getAxes(int i) { Mosaic mosaic = getMosaic(); TileAxis al0 = mosaic.getTileAxisLeft(0); TileAxis al1 = mosaic.getTileAxisLeft(1); TileAxis ab0 = mosaic.getTileAxisBottom(0); TileAxis ab1 = mosaic.getTileAxisBottom(1); TileAxis[] a = null; if (_axesPlacement==AxesPlacement.NONE) { a = new TileAxis[]{}; } else if (_orientation==Orientation.X1DOWN_X2RIGHT) { if (i==1) a = new TileAxis[]{al1}; if (i==2) a = new TileAxis[]{ab0}; if (i==3) a = new TileAxis[]{al0,ab1}; } else if (_orientation==Orientation.X1DOWN_X3RIGHT) { if (i==1) a = new TileAxis[]{al1}; if (i==2) a = new TileAxis[]{al0,ab1}; if (i==3) a = new TileAxis[]{ab0}; } else if (_orientation==Orientation.X1RIGHT_X2UP) { if (i==1) a = new TileAxis[]{ab0}; if (i==2) a = new TileAxis[]{al1}; if (i==3) a = new TileAxis[]{al0,ab1}; } else if (_orientation==Orientation.X1RIGHT_X3UP) { if (i==1) a = new TileAxis[]{ab0}; if (i==2) a = new TileAxis[]{al0,ab1}; if (i==3) a = new TileAxis[]{al1}; } return a; } }
float[] x1 = {0.0f,1.0f}; float[] x2 = {0.0f,1.0f}; Mosaic mosaic = new Mosaic(nrow,ncol,axesPlacement); mosaic.setBackground(Color.WHITE); mosaic.setFont(new Font("SansSerif",Font.PLAIN,12)); mosaic.setWidthMinimum(1,200); mosaic.setWidthElastic(1,200); mosaic.setHeightElastic(0,0); for (int irow=0; irow<nrow; ++irow) { for (int icol=0; icol<ncol; ++icol) { mosaic.getTile(irow,icol).addTiledView(new PointsView(x1,x2)); mosaic.getTileAxisTop(0).setLabel("axis label"); mosaic.getTileAxisTop(1).setLabel("axis label"); mosaic.getTileAxisTop(2).setLabel("axis label"); mosaic.getTileAxisLeft(0).setLabel("axis label"); mosaic.getTileAxisLeft(1).setLabel("axis label"); mosaic.getTileAxisBottom(0).setLabel("axis label"); mosaic.getTileAxisBottom(1).setLabel("axis label"); mosaic.getTileAxisBottom(2).setLabel("axis label"); mosaic.getTileAxisRight(0).setLabel("axis label"); mosaic.getTileAxisRight(1).setLabel("axis label"); TileZoomMode zoomMode = new TileZoomMode(mosaic.getModeManager()); zoomMode.setActive(true);
int jrow = tile.getRowIndex(); int jcol = tile.getColumnIndex(); int nrow = mosaic.countRows(); int ncol = mosaic.countColumns(); for (int irow=0; irow<nrow; ++irow) { if (irow!=jrow) drawZoom(mosaic.getTile(irow,jcol),x,y,true,false); drawZoom(mosaic.getTile(jrow,icol),x,y,false,true); drawZoom(mosaic.getTileAxisTop(jcol),x,y,true,false); drawZoom(mosaic.getTileAxisLeft(jrow),x,y,false,true); drawZoom(mosaic.getTileAxisBottom(jcol),x,y,true,false); drawZoom(mosaic.getTileAxisRight(jrow),x,y,false,true);
/** * Gets the tile adjacent to this axis. * @return the tile. */ public Tile getTile() { if (isTop()) { return _mosaic.getTile(0,_index); } else if (isLeft()) { return _mosaic.getTile(_index,0); } else if (isBottom()) { int irow = _mosaic.countRows()-1; return _mosaic.getTile(irow,_index); } else if (isRight()) { int icol = _mosaic.countColumns()-1; return _mosaic.getTile(_index,icol); } else { return null; } }
/** * Gets the right tile axis for this tile. * @return the axis; null, if none. */ public TileAxis getTileAxisRight() { return _mosaic.getTileAxisRight(_irow); }
/** * Gets the left tile axis for this tile. * @return the axis; null, if none. */ public TileAxis getTileAxisLeft() { return _mosaic.getTileAxisLeft(_irow); }
_l13.setOrientation(PointsView.Orientation.X1DOWN_X2RIGHT); _l23.setOrientation(PointsView.Orientation.X1RIGHT_X2UP); getMosaic().setWidthElastic( 0,100*_n2/_n3); getMosaic().setHeightElastic(0,100*_n3/_n1); } else if (orientation==Orientation.X1DOWN_X3RIGHT) { _transpose23 = true; _l13.setOrientation(PointsView.Orientation.X1DOWN_X2RIGHT); _l23.setOrientation(PointsView.Orientation.X1RIGHT_X2UP); getMosaic().setWidthElastic( 0,100*_n3/_n2); getMosaic().setHeightElastic(0,100*_n2/_n1); } else if (orientation==Orientation.X1RIGHT_X2UP) { _transpose23 = true; _l13.setOrientation(PointsView.Orientation.X1RIGHT_X2UP); _l23.setOrientation(PointsView.Orientation.X1RIGHT_X2UP); getMosaic().setWidthElastic( 0,100*_n1/_n3); getMosaic().setHeightElastic(0,100*_n3/_n2); } else if (orientation==Orientation.X1RIGHT_X3UP) { _transpose23 = false; _l13.setOrientation(PointsView.Orientation.X1RIGHT_X2UP); _l23.setOrientation(PointsView.Orientation.X1RIGHT_X2UP); getMosaic().setWidthElastic( 0,100*_n1/_n2); getMosaic().setHeightElastic(0,100*_n2/_n3);
/** * Gets the tile with specified row and column indices. * @param irow the row index. * @param icol the column index. * @return the tile. */ public Tile getTile(int irow, int icol) { return _mosaic.getTile(irow,icol); }
public void setFont(Font font) { super.setFont(font); if (_mosaic!=null) _mosaic.setFont(font); revalidate(); }
public void setBackground(Color color) { super.setBackground(color); if (_mosaic!=null) _mosaic.setBackground(color); }
/** * Gets the top tile axis for this tile. * @return the axis; null, if none. */ public TileAxis getTileAxisTop() { return _mosaic.getTileAxisTop(_icol); }
/** * Gets the bottom tile axis for this tile. * @return the axis; null, if none. */ public TileAxis getTileAxisBottom() { return _mosaic.getTileAxisBottom(_icol); }
axesPlacementSet = EnumSet.noneOf(Mosaic.AxesPlacement.class); _mosaic = new Mosaic(nrow,ncol,axesPlacementSet); _colorMapHandler = new ColorMapHandler(); GridBagConstraints gbc = new GridBagConstraints();
if (axis.isHorizontal()) { int jcol = axis.getIndex(); int nrow = mosaic.countRows(); for (int irow=0; irow<nrow; ++irow) drawZoom(mosaic.getTile(irow,jcol),x,y,true,false); if (axis.isTop()) { drawZoom(mosaic.getTileAxisBottom(jcol),x,y,true,false); } else { drawZoom(mosaic.getTileAxisTop(jcol),x,y,true,false); int ncol = mosaic.countColumns(); for (int icol=0; icol<ncol; ++icol) drawZoom(mosaic.getTile(jrow,icol),x,y,false,true); if (axis.isLeft()) { drawZoom(mosaic.getTileAxisRight(jrow),x,y,false,true); } else { drawZoom(mosaic.getTileAxisLeft(jrow),x,y,false,true);
/** * Sets the label for this color bar. * @param label the label; null, if none. */ public void setLabel(String label) { _mosaic.getTileAxisRight(0).setLabel(label); revalidate(); }
/** * Sets the format for the vertical axis in the specified row. * @param irow the row index. * @param format the format. */ public void setVFormat(int irow, String format) { if (_axesPlacement!=AxesPlacement.NONE) { _mosaic.getTileAxisLeft(irow).setFormat(format); } }
private void showLines() { Mosaic mosaic = getMosaic(); Tile t00 = mosaic.getTile(0,0); Tile t10 = mosaic.getTile(1,0); Tile t11 = mosaic.getTile(1,1); if (_orientation==Orientation.X1DOWN_X2RIGHT) { t00.addTiledView(_l23); t10.addTiledView(_l12); t11.addTiledView(_l13); } else if (_orientation==Orientation.X1DOWN_X3RIGHT) { t00.addTiledView(_l23); t10.addTiledView(_l13); t11.addTiledView(_l12); } else if (_orientation==Orientation.X1RIGHT_X2UP) { t00.addTiledView(_l13); t10.addTiledView(_l12); t11.addTiledView(_l23); } else if (_orientation==Orientation.X1RIGHT_X3UP) { t00.addTiledView(_l12); t10.addTiledView(_l13); t11.addTiledView(_l23); } } private void hideLines() {
/** * Sets the font in all components of this panel. * Sets the title font to be 1.5 times larger than the specified font. * @param font the font. */ public void setFont(Font font) { super.setFont(font); if (_mosaic!=null) _mosaic.setFont(font); if (_colorBar!=null) _colorBar.setFont(font); if (_title!=null) _title.setFont(font.deriveFont(1.5f*font.getSize2D())); adjustColorBar(); revalidate(); }