Search in sources :

Example 1 with PositiveNumberValidator

use of org.gephi.lib.validation.PositiveNumberValidator in project gephi by gephi.

the class RandomGraphPanel method createValidationPanel.

public static ValidationPanel createValidationPanel(RandomGraphPanel innerPanel) {
    ValidationPanel validationPanel = new ValidationPanel();
    if (innerPanel == null) {
        innerPanel = new RandomGraphPanel();
    }
    validationPanel.setInnerComponent(innerPanel);
    ValidationGroup group = validationPanel.getValidationGroup();
    //Node field
    group.add(innerPanel.nodeField, Validators.REQUIRE_NON_EMPTY_STRING, new PositiveNumberValidator());
    //Edge field
    group.add(innerPanel.edgeField, Validators.REQUIRE_NON_EMPTY_STRING, new BetweenZeroAndOneValidator());
    return validationPanel;
}
Also used : PositiveNumberValidator(org.gephi.lib.validation.PositiveNumberValidator) ValidationGroup(org.netbeans.validation.api.ui.ValidationGroup) BetweenZeroAndOneValidator(org.gephi.lib.validation.BetweenZeroAndOneValidator) ValidationPanel(org.netbeans.validation.api.ui.ValidationPanel)

Example 2 with PositiveNumberValidator

use of org.gephi.lib.validation.PositiveNumberValidator in project gephi by gephi.

the class DynamicSettingsPanel method createValidation.

public void createValidation(ValidationGroup group) {
    GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
    GraphModel graphModel = graphController.getGraphModel();
    TimeFormat timeFormat = graphModel.getTimeFormat();
    if (timeFormat == TimeFormat.DOUBLE) {
        group.add(windowTextField, Validators.REQUIRE_NON_EMPTY_STRING, Validators.numberRange(Double.MIN_VALUE, (bounds.getHigh() - bounds.getLow())));
        group.add(tickTextField, Validators.REQUIRE_NON_EMPTY_STRING, Validators.numberRange(Double.MIN_VALUE, (bounds.getHigh() - bounds.getLow())));
    } else {
        //TODO validation with dates
        group.add(windowTextField, Validators.REQUIRE_NON_EMPTY_STRING, new PositiveNumberValidator(), new DateRangeValidator(windowTimeUnitCombo.getModel()));
        group.add(tickTextField, Validators.REQUIRE_NON_EMPTY_STRING, new PositiveNumberValidator(), new DateRangeValidator(tickTimeUnitCombo.getModel()), new TickUnderWindowValidator(timeFormat != TimeFormat.DOUBLE));
    }
}
Also used : TimeFormat(org.gephi.graph.api.TimeFormat) PositiveNumberValidator(org.gephi.lib.validation.PositiveNumberValidator) GraphModel(org.gephi.graph.api.GraphModel) GraphController(org.gephi.graph.api.GraphController)

Aggregations

PositiveNumberValidator (org.gephi.lib.validation.PositiveNumberValidator)2 GraphController (org.gephi.graph.api.GraphController)1 GraphModel (org.gephi.graph.api.GraphModel)1 TimeFormat (org.gephi.graph.api.TimeFormat)1 BetweenZeroAndOneValidator (org.gephi.lib.validation.BetweenZeroAndOneValidator)1 ValidationGroup (org.netbeans.validation.api.ui.ValidationGroup)1 ValidationPanel (org.netbeans.validation.api.ui.ValidationPanel)1