コード例 #1
0
  public void serializeInto(
      @NotNull Object o, @NotNull Element element, @NotNull SerializationFilter filter) {
    for (Binding binding : myPropertyBindings.keySet()) {
      Accessor accessor = myPropertyBindings.get(binding);
      if (!filter.accepts(accessor, o)) {
        continue;
      }

      // todo: optimize. Cache it.
      Property property = accessor.getAnnotation(Property.class);
      if (property != null && property.filter() != SerializationFilter.class) {
        try {
          if (!ReflectionUtil.newInstance(property.filter()).accepts(accessor, o)) {
            continue;
          }
        } catch (RuntimeException e) {
          throw new XmlSerializationException(e);
        }
      }

      Object node = binding.serialize(o, element, filter);
      if (node != null) {
        if (node instanceof org.jdom.Attribute) {
          element.setAttribute((org.jdom.Attribute) node);
        } else {
          JDOMUtil.addContent(element, node);
        }
      }
    }
  }
コード例 #2
0
 /** Enables the apply button if anything changed. */
 @Override
 public boolean isModified() {
   for (Property property : properties) {
     if (property.isModified()) {
       return true;
     }
   }
   return false;
 }
コード例 #3
0
 public void insertUpdate(DocumentEvent e) {
   Document doc = e.getDocument();
   try {
     prop.set(doc.getText(0, doc.getLength()));
   } catch (BadLocationException b) {
     // Once again, no idea what this is supposed to be.
     // I don't think I like this interface much :-(.
     System.out.println(b);
   }
 }
コード例 #4
0
  private static Binding _createBinding(@NotNull Accessor accessor) {
    Binding binding = XmlSerializerImpl.getTypeBinding(accessor.getGenericType(), accessor);
    if (binding instanceof JDOMElementBinding) {
      return binding;
    }

    Attribute attribute = accessor.getAnnotation(Attribute.class);
    if (attribute != null) {
      return new AttributeBinding(accessor, attribute);
    }

    Tag tag = accessor.getAnnotation(Tag.class);
    if (tag != null && !tag.value().isEmpty()) {
      return new TagBinding(accessor, tag);
    }

    Text text = accessor.getAnnotation(Text.class);
    if (text != null) {
      return new TextBinding(accessor);
    }

    boolean surroundWithTag = true;
    Property property = accessor.getAnnotation(Property.class);
    if (property != null) {
      surroundWithTag = property.surroundWithTag();
    }

    if (!surroundWithTag) {
      if (!Element.class.isAssignableFrom(binding.getBoundNodeType())) {
        throw new XmlSerializationException(
            "Text-serializable properties can't be serialized without surrounding tags: "
                + accessor);
      }
      return new AccessorBindingWrapper(accessor, binding);
    }

    return new OptionTagBinding(accessor, accessor.getAnnotation(OptionTag.class));
  }
コード例 #5
0
  /* (non-Javadoc)
   * @see javax.swing.JTable#getCellRenderer(int, int)
   */
  public TableCellRenderer getCellRenderer(int row, int column) {
    PropertySheetTableModel.Item item = getSheetModel().getPropertySheetElement(row);

    switch (column) {
      case PropertySheetTableModel.NAME_COLUMN:
        // name column gets a custom renderer
        return nameRenderer;

      case PropertySheetTableModel.VALUE_COLUMN:
        {
          if (!item.isProperty()) return nameRenderer;

          // property value column gets the renderer from the factory
          Property property = item.getProperty();
          TableCellRenderer renderer = getRendererFactory().createTableCellRenderer(property);
          if (renderer == null) renderer = getCellRenderer(property.getType());
          return renderer;
        }
      default:
        // when will this happen, given the above?
        return super.getCellRenderer(row, column);
    }
  }
コード例 #6
0
  DigitalWatch() {
    super("DigitalWatch");

    setVisible(true);
    MenuBar mb = new MenuBar();
    setMenuBar(mb);
    Menu menuDisp = new Menu("表示");
    mb.add(menuDisp);
    MenuItem itemProp = new MenuItem(Property.MENU_NAME);
    menuDisp.add(itemProp);
    itemProp.addActionListener(property);
    setBackground(property.getBackground());

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
コード例 #7
0
 public void actionPerformed(ActionEvent e) {
   property.setVisible(true);
 }
コード例 #8
0
ファイル: ProfilePlotPanel.java プロジェクト: Holdlen2DH/nest
  @Override
  protected void initComponents() {
    getAlternativeView().initComponents();
    dataset = new XYIntervalSeriesCollection();
    this.chart =
        ChartFactory.createXYLineChart(
            CHART_TITLE,
            "Path in pixels",
            DEFAULT_SAMPLE_DATASET_NAME,
            dataset,
            PlotOrientation.VERTICAL,
            true,
            true,
            false);
    final XYPlot plot = chart.getXYPlot();

    deviationRenderer = new DeviationRenderer();
    deviationRenderer.setUseFillPaint(true);
    deviationRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    deviationRenderer.setSeriesLinesVisible(0, true);
    deviationRenderer.setSeriesShapesVisible(0, false);
    deviationRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    deviationRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    deviationRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);

    pointRenderer = new XYErrorRenderer();
    pointRenderer.setUseFillPaint(true);
    pointRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    pointRenderer.setSeriesLinesVisible(0, false);
    pointRenderer.setSeriesShapesVisible(0, true);
    pointRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    pointRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    pointRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
    pointRenderer.setSeriesShape(0, StatisticChartStyling.SAMPLE_DATA_POINT_SHAPE);

    configureRendererForCorrelativeData(deviationRenderer);
    configureRendererForCorrelativeData(pointRenderer);

    plot.setNoDataMessage(NO_DATA_MESSAGE);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setRenderer(deviationRenderer);

    final AxisChangeListener axisListener =
        new AxisChangeListener() {
          @Override
          public void axisChanged(AxisChangeEvent event) {
            adjustAxisControlComponents();
          }
        };

    final ValueAxis domainAxis = plot.getDomainAxis();
    final ValueAxis rangeAxis = plot.getRangeAxis();
    // allow transfer from bounds into min/max fields, if auto min/maxis enabled
    domainAxis.setAutoRange(true);
    rangeAxis.setAutoRange(true);

    domainAxis.addChangeListener(axisListener);
    rangeAxis.addChangeListener(axisListener);

    intervalMarkers = new HashSet<IntervalMarker>();

    xAxisRangeControl = new AxisRangeControl("X-Axis");
    yAxisRangeControl = new AxisRangeControl("Y-Axis");

    final PropertyChangeListener changeListener =
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(PROPERTY_NAME_MARK_SEGMENTS)) {
              updateDataSet();
            }
            if (evt.getPropertyName().equals(PROPERTY_NAME_LOG_SCALED)) {
              updateScalingOfYAxis();
            }
            updateUIState();
          }
        };
    xAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener);
    xAxisRangeControl
        .getBindingContext()
        .getPropertySet()
        .addProperty(Property.create(PROPERTY_NAME_MARK_SEGMENTS, false));
    xAxisRangeControl
        .getBindingContext()
        .getPropertySet()
        .getDescriptor(PROPERTY_NAME_MARK_SEGMENTS)
        .setDescription("Toggle whether to mark segments");

    yAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener);
    yAxisRangeControl
        .getBindingContext()
        .getPropertySet()
        .addProperty(Property.create(PROPERTY_NAME_LOG_SCALED, false));
    yAxisRangeControl
        .getBindingContext()
        .getPropertySet()
        .getDescriptor(PROPERTY_NAME_LOG_SCALED)
        .setDescription("Toggle whether to use a logarithmic axis");

    dataSourceConfig = new DataSourceConfig();
    final BindingContext bindingContext =
        new BindingContext(PropertyContainer.createObjectBacked(dataSourceConfig));

    JPanel middlePanel = createMiddlePanel(bindingContext);
    createUI(createChartPanel(chart), middlePanel, bindingContext);

    isInitialized = true;

    updateComponents();
  }
コード例 #9
0
  public void actionPerformed(ActionEvent e) {
    String event = e.getActionCommand();
    moneyLabel.setText("Money Owned:" + x.getMoney() + "");
    jcards.setText("Get out of Jail Cards Owned: " + x.getJailCards());
    if (event.equals("mortgage")
        && (Game.SlotsList[x.getProperties().get(propertydisplay.getSelectedIndex())]
            instanceof Property)) {
      Slot pobject = Game.SlotsList[x.getProperties().get(propertydisplay.getSelectedIndex())];
      if (pobject.getMortgage()) {
        if (JOptionPane.showConfirmDialog(
                null,
                "Would you like to unmortgage your property for $" + pobject.getMortgageV() * 1.10,
                "Mortgage Choice",
                JOptionPane.YES_NO_OPTION)
            == JOptionPane.YES_OPTION) {
          pobject.endMortgage();
        } else {

        }
      } else {
        if (JOptionPane.showConfirmDialog(
                null,
                "Would you like to mortgage your property for $" + pobject.getMortgageV(),
                "Mortgage Choice",
                JOptionPane.YES_NO_OPTION)
            == JOptionPane.YES_OPTION) {
          pobject.mortgageProperty();
        } else {

        }
      }
      // WIP Code!
    } else if (event.equals("buyHouse")) {
      HouseMenu one =
          new HouseMenu(
              x,
              "buy"); // pass along the player and what sort of thing the player wants to be doing
      one.setVisible(true);
      do {
        try {
          TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException a) {
          // nothing
        }
      } while (one.done == false);
      one.dispose();
    } else if (event.equals("sellHouse")) {
      HouseMenu one = new HouseMenu(x, "sell");
      one.setVisible(true);
      do {
        try {
          TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException a) {
          // nothing
        }
      } while (one.done == false);
      one.dispose();
    } else {
      Property choice =
          (Property) (Game.SlotsList[x.getProperties().get(propertydisplay.getSelectedIndex())]);
      int res =
          JOptionPane.showConfirmDialog(
              null,
              "Are you sure you want to sell this property, along with any houses and hotels?",
              "Confirm your choice",
              JOptionPane.YES_NO_OPTION);
      if (res == JOptionPane.YES_OPTION) {
        choice.sellProperty();
      } else {
        // nothing
      }
    }
  }
コード例 #10
0
 /** Restore components to the initial state. */
 private void restoreState() {
   for (Property property : properties) {
     property.restoreState();
   }
 }
コード例 #11
0
 /** Persistent save of the current state. */
 private void saveState() {
   preSaveHook();
   for (Property property : properties) {
     property.saveState();
   }
 }