public void paintIcon(Component c, Graphics g, int x, int y) { Color color = c == null ? Color.GRAY : c.getBackground(); // In a compound sort, make each succesive triangle 20% // smaller than the previous one. int dx = (int) (size / 2 * Math.pow(0.8, priority)); int dy = descending ? dx : -dx; // Align icon (roughly) with font baseline. y = y + 5 * size / 6 + (descending ? -dy : 0); int shift = descending ? 1 : -1; g.translate(x, y); // Right diagonal. g.setColor(color.darker()); g.drawLine(dx / 2, dy, 0, 0); g.drawLine(dx / 2, dy + shift, 0, shift); // Left diagonal. g.setColor(color.brighter()); g.drawLine(dx / 2, dy, dx, 0); g.drawLine(dx / 2, dy + shift, dx, shift); // Horizontal line. if (descending) { g.setColor(color.darker().darker()); } else { g.setColor(color.brighter().brighter()); } g.drawLine(dx, 0, 0, 0); g.setColor(color); g.translate(-x, -y); }
/** * Modelo de tabla que implementa una matriz ortogonal como DDE para representar las series de datos * * @author Erik Giron (200313492) */ public class Hoja extends AbstractTableModel { private int max_col = (int) Math.pow(2, 14); // almacena la columna maxima que se ha alcanzado private int max_row = (int) Math.pow(2, 18); private String id = new String(); private Matriz tabla = new Matriz(); private tda.Dato datoAInsertar = new Dato(); public void setId(String sId) { this.id = sId; } /** * Devuelve el id de la hoja * * @return Identificador de la hoja */ public String getId() { return this.id; } /** Crea una nueva instancia de Hoja */ public Hoja() { id = "Hoja1"; } /** Constructor especificando el String */ public Hoja(String ID) { id = ID; } /** Vacia la matriz */ public void Borrar() { tabla.vaciar(); } /** Obtiene tabla de la hoja */ public Matriz getTabla() { return this.tabla; } /** Inserta una nueva tabla en la hoja */ public void setTabla(Matriz m) { tabla = m; } /** * Devuelve el maximo numero de filas * * @return filas */ public int getRowCount() { return max_row; } /** * Devuelve el maximo numero de columnas * * @return columnas */ public int getColumnCount() { return max_col; } /** Retorna valor al indice establecido */ public Object getValueAt(int row, int column) { if (row == 0 && column == 0) { return ""; } else if (row == 0 && column > 0) { return column; } else if (column == 0 && row > 0) { return row; } else { this.tabla.irA(column, row); if (this.tabla.datoActual() != null) return this.tabla.stringActual(); else return ""; } } /** Retorna verdadero para celdas que se pueden editar */ public boolean isCellEditable(int rowIndex, int columnIndex) { if (rowIndex == 0 || columnIndex == 0) return false; else return true; } /** Ingresa o actualiza dato */ public void setValueAt(Object value, int row, int col) { datoAInsertar.setExpr(value.toString()); this.tabla.insertar(datoAInsertar, col, row); fireTableCellUpdated(row, col); } /** Asigna referencia a la matriz del workplace donde se encuentra contenida */ public void setWorkplace(Workplace wp) { tabla.setWorkplace(wp); } }
/** Get an image based on index numbers */ public BufferedImage getIndexedImage( int x, int y, int zoom, int cacheZoom, GMapListener listener) { if (listener != null) { if (!getGDataSource().isCached(x, y, zoom)) { listener.updateGMapPainting(); listener.updateGMapMessage(GMap.MESSAGE_DOWNLOADING); } else { listener.updateGMapMessage(GMap.MESSAGE_PAINTING); } } BufferedImage thumbImage = getGDataSource().getImage(x, y, zoom, true); if (thumbImage == null) return defaultImage; // if we dont have to paint cache, return here if (cacheZoom == (GPhysicalPoint.MIN_ZOOM - 1) || cacheZoom >= zoom) return thumbImage; BufferedImage paintedImage = new BufferedImage( GDataSource.sourceSize.width, GDataSource.sourceSize.height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics2D = paintedImage.createGraphics(); graphics2D.drawImage( thumbImage, 0, 0, GDataSource.sourceSize.width, GDataSource.sourceSize.height, null); // now lets move to painting the cache double imageNum = Math.pow(2, zoom - cacheZoom); // draw cache lines int startX = (int) (imageNum * x); int startY = (int) (imageNum * y); // get composite to restore later, set new transparent composite Composite originalComposite = graphics2D.getComposite(); graphics2D.setComposite(opacity40); // draw grid for (int i = 0; i < imageNum; i++) { for (int j = 0; j < imageNum; j++) { // points Point upperLeft = new Point( (int) (GDataSource.sourceSize.width / imageNum) * i, (int) (GDataSource.sourceSize.height / imageNum) * j); Dimension size = new Dimension( (int) (GDataSource.sourceSize.width / imageNum), (int) (GDataSource.sourceSize.height / imageNum)); // draw lines graphics2D.setColor(new Color(100, 100, 100)); graphics2D.drawLine(upperLeft.x, upperLeft.y, upperLeft.x + size.width, upperLeft.y); graphics2D.drawLine(upperLeft.x, upperLeft.y, upperLeft.x, upperLeft.y + size.height); // check if file exists if (getGDataSource().isCached(startX + i, startY + j, cacheZoom)) graphics2D.setColor(Color.RED); else graphics2D.setColor(new Color(155, 155, 155)); // shade rectangle graphics2D.fillRect(upperLeft.x, upperLeft.y, size.width, size.height); } } // restore composite graphics2D.setComposite(originalComposite); return paintedImage; }