Examples of TableModel


Examples of javax.swing.table.TableModel

      throws ParseException
  {
    final URL in = ObjectUtilities.getResource
        ("org/pentaho/reporting/engine/classic/demo/opensource/opensource.xml", StraightToEverything.class);
    final MasterReport report = parseReport(in);
    final TableModel data = new OpenSourceProjects();
    report.setDataFactory(new TableDataFactory
        ("default", data));
    try
    {
      createPDF(report, filename + ".pdf");
View Full Code Here

Examples of javax.swing.table.TableModel

      throws ParseException
  {
    final URL in = ObjectUtilities.getResource
        ("org/pentaho/reporting/engine/classic/demo/opensource/opensource.xml", StraightToXML.class);
    final MasterReport report = parseReport(in);
    final TableModel data = new OpenSourceProjects();
    report.setDataFactory(new TableDataFactory
        ("default", data));
    saveXML(report, filename);
  }
View Full Code Here

Examples of javax.swing.table.TableModel

      throws ParseException
  {
    final URL in = ObjectUtilities.getResource
        ("org/pentaho/reporting/engine/classic/demo/opensource/opensource.xml", StraightToPNG.class);
    final MasterReport report = parseReport(in);
    final TableModel data = new OpenSourceProjects();
    report.setDataFactory(new TableDataFactory
        ("default", data));
    final long startTime = System.currentTimeMillis();
    savePNG(report, filename);
  }
View Full Code Here

Examples of javax.swing.table.TableModel

      throws ParseException
  {
    final URL in = ObjectUtilities.getResource
        ("org/pentaho/reporting/engine/classic/demo/opensource/opensource.xml", StraightToPDF.class);
    final MasterReport report = parseReport(in);
    final TableModel data = new OpenSourceProjects();
    report.setDataFactory(new TableDataFactory("default", data));
    final long startTime = System.currentTimeMillis();
    savePDF(report, filename);
  }
View Full Code Here

Examples of javax.swing.table.TableModel

      throws ParseException
  {
    final URL in = ObjectUtilities.getResource
        ("org/pentaho/reporting/engine/classic/demo/opensource/opensource.xml", StraightToPlainText.class);
    final MasterReport report = parseReport(in);
    final TableModel data = new OpenSourceProjects();
    report.setDataFactory(new TableDataFactory
        ("default", data));
    savePlainText(report, filename);
  }
View Full Code Here

Examples of javax.swing.table.TableModel

  public static void main(String[] args)
      throws ReportProcessingException
  {
    ClassicEngineBoot.getInstance().start();

    final TableModel data = new DefaultTableModel(1, 1);
    final MasterReport report = TestSystem.loadReport("org/pentaho/reporting/engine/classic/extensions/junit/pages/valign-report.xml", data);
    if (report == null)
    {
      System.exit(1);
    }
View Full Code Here

Examples of javax.swing.table.TableModel

  }

  public void testPageSystem()   throws Exception
  {
    ClassicEngineBoot.getInstance().start();
    final TableModel data = new DefaultTableModel(2000, 1);
    MasterReport report = parseReport(getReportDefinitionSource());
    report.setDataFactory(new TableDataFactory
        ("default", data)); //$NON-NLS-1$;
    assertTrue(FunctionalityTestLib.execGraphics2D(report));
  }
View Full Code Here

Examples of javax.swing.table.TableModel

    // second run. Now with padding ..
    final ProcessingContext prc = new DefaultProcessingContext();
    final GlobalMasterRow gmr = GlobalMasterRow.createReportRow
        (prc, new DefaultDataSchemaDefinition(), new ParameterDataRow(), null, false);
    final TableModel data = createTableModel();
    MasterDataRow wdata = gmr.deriveWithQueryData(new ReportDataRow(data));
    int advanceCount = 0;
    wdata = wdata.startCrosstabMode(specification);
    logger.debug("Region:  " + wdata.getGlobalView().get("Region"));
    logger.debug("Product: " + wdata.getGlobalView().get("Product"));
    logger.debug("Year:    " + wdata.getGlobalView().get("Time"));
    Object grpVal = wdata.getGlobalView().get("Region");
    while (wdata.isAdvanceable())
    {
      logger.debug("-- Advance -- ");
      MasterDataRow nextdata = wdata.advance();
      Object nextGrpVal = nextdata.getGlobalView().get("Region");
      if (ObjectUtilities.equal(grpVal, nextGrpVal) == false)
      {
        nextdata = nextdata.resetRowCursor();
      }

      logger.debug("Do Advance Count: " + nextdata.getReportDataRow().getCursor());
      logger.debug("Region:  " + nextdata.getGlobalView().get("Region"));
      logger.debug("Product: " + nextdata.getGlobalView().get("Product"));
      logger.debug("Year:    " + nextdata.getGlobalView().get("Time"));
      advanceCount += 1;
      wdata = nextdata;
      grpVal = nextGrpVal;
    }
    if (advanceCount != (data.getRowCount() - 1))
    {
      throw new IllegalStateException("Expected " + (data.getRowCount() - 1) + " but got " + advanceCount);
    }

  }
View Full Code Here

Examples of javax.swing.table.TableModel

  private static CrosstabSpecification buildCS()
  {
    final ProcessingContext prc = new DefaultProcessingContext();
    final GlobalMasterRow gmr = GlobalMasterRow.createReportRow
        (prc, new DefaultDataSchemaDefinition(), new ParameterDataRow(), null, false);
    final TableModel data = createTableModel();
    MasterDataRow wdata = gmr.deriveWithQueryData(new ReportDataRow(data));
    final CrosstabSpecification cs = new SortedMergeCrosstabSpecification
        (createDummyKey(), new String[]{"Product", "Time"});
    int advanceCount = 0;
    System.out.println(wdata.getReportDataRow().getCursor());
    cs.startRow();
    cs.add(wdata.getGlobalView());
    Object grpVal = wdata.getGlobalView().get("Region");
    while (wdata.isAdvanceable())
    {
      final MasterDataRow nextdata = wdata.advance();
      Object nextGrpVal = nextdata.getGlobalView().get("Region");
      if (ObjectUtilities.equal(grpVal, nextGrpVal) == false)
      {
        cs.endRow();
        cs.startRow();
      }

      cs.add(nextdata.getGlobalView());
      logger.debug("Prepare Advance Count: " + nextdata.getReportDataRow().getCursor());
      advanceCount += 1;
      wdata = nextdata;
      grpVal = nextGrpVal;
    }
    cs.endRow();
    if (advanceCount != (data.getRowCount() - 1))
    {
      throw new IllegalStateException("Expected 6 but got " + advanceCount);
    }
    return cs;
  }
View Full Code Here

Examples of javax.swing.table.TableModel

    fireTableChanged(new TableModelEvent(this, TableModelEvent.HEADER_ROW));
  }

  public int compareRowsByColumn(int row1, int row2, int column) {
    Class type = model.getColumnClass(column);
    TableModel data = model;

    // Check for nulls

    Object o1 = data.getValueAt(row1, column);
    Object o2 = data.getValueAt(row2, column);

    // If both values are null return 0
    if (o1 == null && o2 == null) {
      return 0;
    } else if (o1 == null) { // Define null less than everything.
      return -1;
    } else if (o2 == null) {
      return 1;
    }

    /* We copy all returned values from the getValue call in case
    an optimised model is reusing one object to return many values.
    The Number subclasses in the JDK are immutable and so will not be used in
    this way but other subclasses of Number might want to do this to save
    space and avoid unnecessary heap allocation.
    */
    if (type.getSuperclass() == java.lang.Number.class) {
      Number n1 = (Number) data.getValueAt(row1, column);
      double d1 = n1.doubleValue();
      Number n2 = (Number) data.getValueAt(row2, column);
      double d2 = n2.doubleValue();

      if (d1 < d2)
        return -1;
      else if (d1 > d2)
        return 1;
      else
        return 0;
    } else if (type == java.util.Date.class) {
      Date d1 = (Date) data.getValueAt(row1, column);
      long n1 = d1.getTime();
      Date d2 = (Date) data.getValueAt(row2, column);
      long n2 = d2.getTime();

      if (n1 < n2)
        return -1;
      else if (n1 > n2)
        return 1;
      else
        return 0;
    } else if (type == String.class) {
      String s1 = (String) data.getValueAt(row1, column);
      String s2 = (String) data.getValueAt(row2, column);
      int result = s1.compareTo(s2);

      if (result < 0)
        return -1;
      else if (result > 0)
        return 1;
      else
        return 0;
    } else if (type == Boolean.class) {
      Boolean bool1 = (Boolean) data.getValueAt(row1, column);
      boolean b1 = bool1.booleanValue();
      Boolean bool2 = (Boolean) data.getValueAt(row2, column);
      boolean b2 = bool2.booleanValue();

      if (b1 == b2)
        return 0;
      else if (b1) // Define false < true
        return 1;
      else
        return -1;
    } else if (type == Comparable.class) {
      Comparable c1 = (Comparable) data.getValueAt(row1, column);
      Comparable c2 = (Comparable) data.getValueAt(row2, column);
      return c1.compareTo(c2);
    } else {
      Object v1 = data.getValueAt(row1, column);
      String s1 = v1.toString();
      Object v2 = data.getValueAt(row2, column);
      String s2 = v2.toString();
      int result = s1.compareTo(s2);

      if (result < 0)
        return -1;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.