/** Inform simulation and editBox of new positions. */ @Override public void dragged(Vec3d dist) { KeywordIndex kw = InputAgent.formatPointsInputs(pointsInput.getKeyword(), pointsInput.getValue(), dist); InputAgent.apply(this, kw); super.dragged(dist); }
{ lengthInput = new ValueInput("Length", "Key Inputs", 1.0d); lengthInput.setValidRange(0.0, Double.POSITIVE_INFINITY); lengthInput.setUnitType(DistanceUnit.class); this.addInput(lengthInput); heightChangeInput = new ValueInput("HeightChange", "Key Inputs", 0.0d); heightChangeInput.setValidRange(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); heightChangeInput.setUnitType(DistanceUnit.class); this.addInput(heightChangeInput); roughnessInput = new ValueInput("Roughness", "Key Inputs", 0.0d); roughnessInput.setValidRange(0.0, Double.POSITIVE_INFINITY); roughnessInput.setUnitType(DistanceUnit.class); this.addInput(roughnessInput); pressureLossCoefficientInput = new ValueInput("PressureLossCoefficient", "Key Inputs", 0.0d); pressureLossCoefficientInput.setValidRange(0.0, Double.POSITIVE_INFINITY); pressureLossCoefficientInput.setUnitType(DimensionlessUnit.class); this.addInput(pressureLossCoefficientInput); ArrayList<Vec3d> defPoints = new ArrayList<>(); defPoints.add(new Vec3d(0.0d, 0.0d, 0.0d)); defPoints.add(new Vec3d(1.0d, 0.0d, 0.0d)); pointsInput = new Vec3dListInput("Points", "Key Inputs", defPoints); pointsInput.setValidCountRange(2, Integer.MAX_VALUE); pointsInput.setUnitType(DistanceUnit.class); this.addInput(pointsInput); widthInput = new ValueInput("Width", "Key Inputs", 1.0d); widthInput.setValidRange(1.0d, Double.POSITIVE_INFINITY); widthInput.setUnitType(DimensionlessUnit.class); this.addInput(widthInput); colourInput = new ColourInput("Colour", "Key Inputs", ColourInput.BLACK); this.addInput(colourInput); this.addSynonym(colourInput, "Color"); }
@Override public HasScreenPoints.PointsInfo[] getScreenPoints() { synchronized (screenPointLock) { if (cachedPointInfo == null) { cachedPointInfo = new HasScreenPoints.PointsInfo[1]; HasScreenPoints.PointsInfo pi = new HasScreenPoints.PointsInfo(); cachedPointInfo[0] = pi; pi.points = pointsInput.getValue(); pi.color = colourInput.getValue(); pi.width = widthInput.getValue().intValue(); if (pi.width < 1) pi.width = 1; } return cachedPointInfo; } }