コード例 #1
0
ファイル: Notepad.java プロジェクト: ArcherSys/ArcherSysRuby
    @Override
    @SuppressWarnings("SleepWhileHoldingLock")
    public void run() {
      try {
        // initialize the statusbar
        status.removeAll();
        JProgressBar progress = new JProgressBar();
        progress.setMinimum(0);
        progress.setMaximum(doc.getLength());
        status.add(progress);
        status.revalidate();

        // start writing
        Writer out = new FileWriter(f);
        Segment text = new Segment();
        text.setPartialReturn(true);
        int charsLeft = doc.getLength();
        int offset = 0;
        while (charsLeft > 0) {
          doc.getText(offset, Math.min(4096, charsLeft), text);
          out.write(text.array, text.offset, text.count);
          charsLeft -= text.count;
          offset += text.count;
          progress.setValue(offset);
          try {
            Thread.sleep(10);
          } catch (InterruptedException e) {
            Logger.getLogger(FileSaver.class.getName()).log(Level.SEVERE, null, e);
          }
        }
        out.flush();
        out.close();
      } catch (IOException e) {
        final String msg = e.getMessage();
        SwingUtilities.invokeLater(
            new Runnable() {

              public void run() {
                JOptionPane.showMessageDialog(
                    getFrame(),
                    "Could not save file: " + msg,
                    "Error saving file",
                    JOptionPane.ERROR_MESSAGE);
              }
            });
      } catch (BadLocationException e) {
        System.err.println(e.getMessage());
      }
      // we are done... get rid of progressbar
      status.removeAll();
      status.revalidate();
    }
コード例 #2
0
  /** Test of evaluateAt method, of class ParameterisedGroup. */
  @Test
  public void testEvaluateAt() throws ParameterException {
    System.out.println("---  testEvaluateAt...");

    // SegmentLocation loc1 = new PostSynapticTerminalLocation(d2.getSegmentId(), 0.5f);

    assertEquals(0.5, pg1.evaluateAt(cell, d2, 0.5f), 0);
    assertEquals(15, pg2.evaluateAt(cell, d2, 0.5f), 0);

    //////// assertEquals(15, pg5.evaluateAt(cell, loc1), 0);

    // SegmentLocation loc2 = new PostSynapticTerminalLocation(d3.getSegmentId(), 0.5f);

    assertEquals(5d / 6d, pg1.evaluateAt(cell, d3, 0.5f), 1e-7);
    assertEquals(25, pg2.evaluateAt(cell, d3, 0.5f), 0);

    assertEquals(0.5, pg3.evaluateAt(cell, d3, 0.5f), 0);

    assertEquals(0, pg4.evaluateAt(cell, d3, 0), 0);
    assertEquals(5, pg4.evaluateAt(cell, d3, 0.5f), 0);

    SegmentLocation sl1 = new SegmentLocation(d3.getSegmentId(), 0.5f);

    assertEquals(
        25,
        pg5.evaluateAt(cell, cell.getSegmentWithId(sl1.getSegmentId()), sl1.getFractAlong()),
        0);

    assertEquals(30, pg5.evaluateAt(cell, d3, 1), 0);

    GenesisCompartmentalisation g = new GenesisCompartmentalisation();

    Cell gCell = g.getCompartmentalisation(cell);

    System.out.println(CellTopologyHelper.printDetails(cell, null));

    System.out.println(
        "Changed from morph: " + cell.getMorphSummary() + ", to morph: " + gCell.getMorphSummary());

    System.out.println("getSegmentMapper: " + g.getSegmentMapper());

    System.out.println(CellTopologyHelper.printDetails(gCell, null));

    SegmentLocation sl1_g = g.getSegmentMapper().mapSegmentLocation(sl1);

    System.out.println("Mapped: " + sl1 + " to " + sl1_g);

    assertEquals(
        25,
        pg5.evaluateAt(gCell, gCell.getSegmentWithId(sl1_g.getSegmentId()), sl1_g.getFractAlong()),
        0);
  }
コード例 #3
0
  @Before
  public void setUp() {
    System.out.println("---------------   setUp() ParameterisedGroupTest");

    cell = new OneSegment("Simple");

    d1 =
        cell.addDendriticSegment(
            1, "d1", new Point3f(10, 0, 0), cell.getFirstSomaSegment(), 1, "Sec1", false);
    d2 = cell.addDendriticSegment(2, "d2", new Point3f(20, 0, 0), d1, 1, "Sec2", false);
    d3 = cell.addDendriticSegment(7, "d3", new Point3f(20, 10, 0), d2, 1, "Sec3", false);

    d3.getSection().setStartRadius(3);

    d1.getSection().setNumberInternalDivisions(4);
    d2.getSection().setNumberInternalDivisions(3);
    d3.getSection().setNumberInternalDivisions(5);

    d3.getSection().addToGroup(tipSection);

    pg1 =
        new ParameterisedGroup(
            "ZeroToOne",
            Section.DENDRITIC_GROUP,
            Metric.PATH_LENGTH_FROM_ROOT,
            ProximalPref.MOST_PROX_AT_0,
            DistalPref.MOST_DIST_AT_1,
            "p1");

    pg2 =
        new ParameterisedGroup(
            "StartToEnd",
            Section.DENDRITIC_GROUP,
            Metric.PATH_LENGTH_FROM_ROOT,
            ProximalPref.NO_TRANSLATION,
            DistalPref.NO_NORMALISATION,
            "p2");

    pg3 =
        new ParameterisedGroup(
            "TipZeroToOne",
            tipSection,
            Metric.PATH_LENGTH_FROM_ROOT,
            ProximalPref.MOST_PROX_AT_0,
            DistalPref.MOST_DIST_AT_1,
            "p3");

    pg4 =
        new ParameterisedGroup(
            "TipToEnd",
            tipSection,
            Metric.PATH_LENGTH_FROM_ROOT,
            ProximalPref.MOST_PROX_AT_0,
            DistalPref.NO_NORMALISATION,
            "p4");

    pg5 =
        new ParameterisedGroup(
            "TipToEnd_PathFromRoot",
            tipSection,
            Metric.PATH_LENGTH_FROM_ROOT,
            ProximalPref.NO_TRANSLATION,
            DistalPref.NO_NORMALISATION,
            "p5");

    /*
    pg5 = new ParameterisedGroup("3DDistZeroToOne",
                               Section.ALL,
                               Metric.THREE_D_RADIAL_POSITION,
                               ProximalPref.MOST_PROX_AT_0,
                               DistalPref.MOST_DIST_AT_1);*/

  }