Package com.visitrend.ndvis.colormapper.model

Examples of com.visitrend.ndvis.colormapper.model.DiscreteOrGradientColor


            // there should be only two columns in the map
            // 0 = query
            // 1 = DiscreteOrGradientColor color assigned to result set rows
            Vector row = (Vector) dataVector.get(k);
            String q = (String) row.get(0);
            DiscreteOrGradientColor col = (DiscreteOrGradientColor) row.get(1);

            // try the query
            try {
                if (sql == null) {
                    JOptionPane.showMessageDialog(colorQueryPanel, "Please make a new connection, this"
                            + " one is dead\nor not providing relevant data...");
                } else {
                    Statement sqlstatement = sql.createStatement(
                            ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
                    rs = sqlstatement.executeQuery(q);
                }
            } catch (SQLException e1) {
                e1.printStackTrace();
                // there was a problem with the query
                int answer = JOptionPane.showConfirmDialog(
                        null,
                        "The query on row "
                        + k
                        + " failed with these warnings:\n"
                        + e1.getMessage()
                        + "\n Would you like me to continue trying the rest?",
                        "Query Error", JOptionPane.YES_NO_OPTION);
                if (answer == JOptionPane.OK_OPTION) {
                    // skip the rest of the for loop and
                    // go immediately to the next query
                    continue;
                } else {
                    cancel();
                    return null;
                }
            }

            // rs is set to null if the user cancels,
            // in which case we'll cancel and return null
            if (null == rs) {
                cancel();
                return null;
            }

            // make sure we can map from ResultSet columns to vis dimensions
            try {
                /*
                 * In order to map every row of a ResultSet to a pixel in an
                 * image, we either need the DataInfo.computedPrimaryKey _or_
                 * DataInfo.parameterNames to be specified as columns in the
                 * ResultSet. We make sure that is the case here. TODO: it would
                 * be great if you could make this check using the String query,
                 * before the query is actually executed. I just didn't feel
                 * like trying to figure out the parsing right now.
                 */
                ResultSetMetaData meta = rs.getMetaData();
                int[] indices = ResultSetParser.getIndices(meta, dataInfo);
                if (!ResultSetParser.checkIndices(indices)) {
                    int answer = JOptionPane.showConfirmDialog(
                            null,
                            "The query must include either a primary key that is computed \n"
                            + "from the parameters or it must include those parameters \n"
                            + "themselves in the select statement. For the query on row \n"
                            + k
                            + " this is not the case. \n"
                            + "Would you like me to continue trying the rest of the queries?",
                            "Qeury Error", JOptionPane.YES_NO_OPTION);
                    if (answer == JOptionPane.OK_OPTION) {
                        // skip the rest of the for loop and
                        // go immediately to the next query
                        continue;
                    } else {
                        cancel();
                        return null;
                    }
                }
               
                if (col.isDiscreteOrGradient()) {
                    rgb = processResultSetForGradientColor(sql, q, rs, col, rgb);
                } else {
                    rgb = processResultSetForDiscreteColor(rs,
                            col.getColorOne(), rgb);
                }
                /*
                 * TODO: if you have one query that has bad syntax, and it asks
                 * if you want to continue with the other queries, and you click
                 * yes, then it fails here because you're out of the for loop? -


  }

  private static void setGradient(DiscreteOrGradientColor grad) {
    if (grad == null) {
      System.out.println("gradient is null");
      grad = new DiscreteOrGradientColor();
    }
    DiscreteOrGradientColorChooserDialog.gradient = grad;

    // set whether its a gradient or not on the choices JComboBox
    if (DiscreteOrGradientColorChooserDialog.gradient

     * leaves one blank line for creating a new query.
     */
    public void clearQueries() {
        Vector v = new Vector();
        v.add(new String(""));
        DiscreteOrGradientColor grad = new DiscreteOrGradientColor();
        grad.setColorOne(Color.BLACK);
        v.add(grad);
        Vector data = new Vector();
        colorQueryPanel.setQueries(data);
    }

        panel = this;
       
        // one blank row to start
        Vector v = new Vector();
        v.add(new String(""));
        DiscreteOrGradientColor grad = new DiscreteOrGradientColor();
        grad.setColorOne(Color.BLACK);
        v.add(grad);
        Vector data = new Vector();
        // add the blank row to data vector, a vector of vectors
        data.add(v);
        columnNames = new Vector();

        }

        public void actionPerformed(ActionEvent e) {
            Vector v = new Vector();
            v.add(new String(""));
            DiscreteOrGradientColor dogc = new DiscreteOrGradientColor();
            dogc.setColorOne(Color.BLACK);
            // v.add(Color.WHITE);
            v.add(dogc);
            growingTableModel.insertRow(growingTableModel.getRowCount(), v);
        }

TOP

Related Classes of com.visitrend.ndvis.colormapper.model.DiscreteOrGradientColor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.