List of usage examples for java.lang Math toRadians
public static double toRadians(double angdeg)
From source file:au.com.addstar.truehardcore.TrueHardcore.java
public Location GetNewLocation(World world, int oldX, int oldZ, int dist) { Location l = new Location(world, oldX, 255, oldZ); Debug("Selecting spawn point " + dist + " blocks from: " + l.getBlockX() + " / " + l.getBlockY() + " / " + l.getBlockZ());//w w w . jav a2 s. c o m double x; double z; int deg; Location nl = null; // Only try to find a good place 30 times for (int count = 0; count < 30; count++) { boolean GoodSpawn = false; Location spawn = null; String reason = ""; // Lets do some trig!! dist = dist + (int) (Math.random() * 100); // Random radius padding deg = (int) (Math.random() * 360); // Random degrees x = (dist * Math.cos(Math.toRadians(deg))) + l.getBlockX(); z = (dist * Math.sin(Math.toRadians(deg))) + l.getBlockZ(); nl = new Location(world, x, 255, z); // Get the highest block at the selected location Block b = nl.getBlock(); while ((b.getType() == Material.AIR) && (b.getY() > 1)) { b = b.getRelative(BlockFace.DOWN); } spawn = new Location(b.getWorld(), b.getX(), b.getY() + 2, b.getZ()); if (SpawnBlocks.contains(b.getType())) { if (spawn.getBlockX() >= 0) { spawn.setX(spawn.getBlockX() + 0.5); } if (spawn.getBlockX() < 0) { spawn.setX(spawn.getBlockX() - 0.5); } if (spawn.getBlockZ() >= 0) { spawn.setZ(spawn.getBlockZ() + 0.5); } if (spawn.getBlockZ() < 0) { spawn.setZ(spawn.getBlockZ() - 0.5); } // Make sure it's inside the world border (if one exists) if (InsideWorldBorder(spawn)) { GoodSpawn = true; reason = "Allowed block type (" + b.getType() + ")!"; } else { reason = "Outside world border"; } } else { reason = "Wrong block type (" + b.getType() + ")"; } if (GoodSpawn) { Debug("GOOD: " + Util.padLeft(String.valueOf(spawn.getX()), 9) + Util.padLeft(String.valueOf(spawn.getY()), 7) + Util.padLeft(String.valueOf(spawn.getZ()), 9) + " (" + dist + " blocks away)" + " => " + reason); // Return the good location spawn.setPitch(0F); spawn.setYaw(0F); return spawn; } else { Debug("BAD : " + Util.padLeft(String.valueOf(spawn.getX()), 9) + Util.padLeft(String.valueOf(spawn.getY()), 7) + Util.padLeft(String.valueOf(spawn.getZ()), 9) + " (" + dist + " blocks away)" + " => " + reason); } } return null; }
From source file:app.akexorcist.gdaplibrary.GoogleDirection.java
private LatLng getNewPosition(LatLng begin, LatLng end) { double lat = Math.abs(begin.latitude - end.latitude); double lng = Math.abs(begin.longitude - end.longitude); double dis = Math.sqrt(Math.pow(lat, 2) + Math.pow(lng, 2)); if (dis >= animateDistance) { double angle = -1; if (begin.latitude <= end.latitude && begin.longitude <= end.longitude) angle = Math.toDegrees(Math.atan(lng / lat)); else if (begin.latitude > end.latitude && begin.longitude <= end.longitude) angle = (90 - Math.toDegrees(Math.atan(lng / lat))) + 90; else if (begin.latitude > end.latitude && begin.longitude > end.longitude) angle = Math.toDegrees(Math.atan(lng / lat)) + 180; else if (begin.latitude <= end.latitude && begin.longitude > end.longitude) angle = (90 - Math.toDegrees(Math.atan(lng / lat))) + 270; double x = Math.cos(Math.toRadians(angle)) * animateDistance; double y = Math.sin(Math.toRadians(angle)) * animateDistance; totalAnimateDistance += animateDistance; double finalLat = begin.latitude + x; double finalLng = begin.longitude + y; return new LatLng(finalLat, finalLng); } else {/*from w ww . j a v a2 s. c o m*/ return end; } }
From source file:com.spoiledmilk.ibikecph.navigation.SMRouteNavigationMapFragment.java
public void animateMap(Location location) { if (getTrackingMode() && !noTracking) { int orientation = (int) route.lastCorrectedHeading; if (orientation < 0) orientation += 360;//from w ww. j a v a 2 s . c om if (!mapView.directionShown || !routingStarted) { // || locationOverlay.isTooFarFromRoute orientation = 0; } int instructionsViewHeight = Util.dp2px(70); if (!mapView.directionShown && ((SMRouteNavigationActivity) getMapActivity()).instructionsViewState == InstrcutionViewState.Normal) { mapView.locationArrowOffsset = -instructionsViewHeight; } else if (((SMRouteNavigationActivity) getMapActivity()).instructionsViewState == InstrcutionViewState.Normal) { mapView.locationArrowOffsset = 0; mapView.locationArrowOffsset -= instructionsViewHeight; mapView.locationArrowOffsset += ((Util.getScreenHeight() - instructionsViewHeight) / 6); } else { mapView.locationArrowOffsset = (int) (Util.getScreenHeight() / 6); } if (location != null) { mapView.getController().animateToForTracking(location.getLatitude(), location.getLongitude(), Math.toRadians(orientation), mapView.locationArrowOffsset, routingStarted); } } }
From source file:com.l2jfree.gameserver.gameobjects.ai.AbstractAI.java
/** * Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn <I>(broadcast)</I>.<BR> * <BR>/*from ww w .j a va2 s . c o m*/ * <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT><BR> * <BR> */ protected void moveToPawn(L2Object pawn, int offset) { // Check if actor can move if (!_actor.isMovementDisabled()) { int minOffset = _actor.getTemplate().getCollisionRadius(); if (pawn instanceof L2Creature) minOffset += ((L2Creature) pawn).getTemplate().getCollisionRadius(); offset = L2Math.max(10, offset, minOffset); // prevent possible extra calls to this function (there is none?), // also don't send movetopawn packets too often boolean sendPacket = true; if (_clientMoving && getTarget() == pawn) { if (_clientMovingToPawnOffset == offset) { if (GameTimeManager.getGameTicks() < _moveToPawnTimeout) return; sendPacket = false; } else if (_actor.isOnGeodataPath()) { // minimum time to calculate new route is 2 seconds if (GameTimeManager.getGameTicks() < (_moveToPawnTimeout + 10)) return; } } // Set AI movement data _clientMoving = true; _clientMovingToPawnOffset = offset; setTarget(pawn); _moveToPawnTimeout = GameTimeManager.getGameTicks(); _moveToPawnTimeout += /*1000*/200 / GameTimeManager.MILLIS_IN_TICK; if (pawn == null || _accessor == null) return; // if the target runs towards the character then don't force the actor to run over it if (pawn instanceof L2Creature && pawn.isMoving()) { double speed = ((L2Creature) pawn).getStat().getMoveSpeed() / GameTimeManager.TICKS_PER_SECOND; offset += speed * Math.cos(Math.toRadians(Util.getAngleDifference(_actor, pawn))); } // Calculate movement data for a move to location action and add the actor to movingObjects of GameTimeController _accessor.moveTo(pawn.getX(), pawn.getY(), pawn.getZ(), offset); if (!_actor.isMoving()) { _actor.sendPacket(ActionFailed.STATIC_PACKET); return; } // Send a Server->Client packet MoveToPawn/MoveToLocation to the actor and all L2Player in its _knownPlayers if (pawn instanceof L2Creature) { if (_actor.isOnGeodataPath()) { _actor.broadcastPacket(new MoveToLocation(_actor)); _clientMovingToPawnOffset = 0; } else if (sendPacket) // don't repeat unnecessarily _actor.broadcastPacket(new MoveToPawn(_actor, (L2Creature) pawn, _clientMovingToPawnOffset)); } else _actor.broadcastPacket(new MoveToLocation(_actor)); } else { clientActionFailed(); } }
From source file:org.interpss.mapper.editor.AclfFormDataMapperImpl.java
private static boolean setPSXfrAdjBranchFormInfo(GBranchForm formBranch, AclfBranch branch, AclfNetwork net, IPSSMsgHub msg) throws InterpssException { AclfAdjBranchData adjData = formBranch.getAcscBranchData(); if (adjData.isHasPSXfrPControl()) { PSXfrPControl psXfrControl = CoreObjectFactory.createPSXfrPControl(branch, AdjControlType.POINT_CONTROL); psXfrControl.setPSpecified(adjData.getPcPSpec()); psXfrControl.setAngLimit(/*from w w w. ja va 2 s .c o m*/ new LimitType(Math.toRadians(adjData.getPcAngMax()), Math.toRadians(adjData.getPcAngMin()))); psXfrControl.setControlOnFromSide(adjData.isPcOnFromSide()); psXfrControl.setFlowFrom2To(adjData.isFlowFrom2To()); } return true; }
From source file:com.funambol.foundation.util.MediaUtils.java
/** * Rotates given buffered image by given amount of degree. * The valid degree values are 0, 90, 180, 270. * If the image is a jpg, the rotation is lossless, exif data are preserved * and image size is almost the same./* ww w . j a v a2 s . co m*/ * * @param bufImage the buffered image * @param degree amount of degree to apply * @return a buffered image containing rotated image data * @throws PicturesException if amount of degree is invalid or if an * IOException occurs */ private static BufferedImage rotateImage(BufferedImage bufImage, int degree) throws FileDataObjecyUtilsException { degree = degree % 360; int h; int w; switch (degree) { case 0: case 180: h = bufImage.getHeight(); w = bufImage.getWidth(); break; case 90: case 270: h = bufImage.getWidth(); w = bufImage.getHeight(); break; default: throw new FileDataObjecyUtilsException( "Error rotating image since the '" + degree + "' degree value is unsupported"); } BufferedImage out = null; int bufImageType = bufImage.getType(); if (BufferedImage.TYPE_BYTE_INDEXED == bufImageType || BufferedImage.TYPE_BYTE_BINARY == bufImageType) { IndexColorModel model = (IndexColorModel) bufImage.getColorModel(); out = new BufferedImage(w, h, bufImage.getType(), model); } else if (BufferedImage.TYPE_CUSTOM == bufImageType) { // we don't know what type of image it can be // there's a bug in some VM that cause some PNG images to have // type custom: this should take care of this issue //check if we need to have alpha channel boolean alpha = bufImage.getTransparency() != BufferedImage.OPAQUE; if (alpha) { // TYPE_INT_ARGB_PRE gives you smaller output images // than TYPE_INT_ARGB out = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE); } else { out = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); } } else { out = new BufferedImage(w, h, bufImage.getType()); } Graphics2D g2d = out.createGraphics(); Map renderingHints = new HashMap(); renderingHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); renderingHints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2d.setRenderingHints(renderingHints); g2d.rotate(Math.toRadians(degree)); switch (degree) { case 90: g2d.translate(0, -w); break; case 180: g2d.translate(-w, -h); break; case 270: g2d.translate(-h, 0); break; } g2d.drawImage(bufImage, null, 0, 0); g2d.dispose(); return out; }
From source file:org.openstreetmap.josm.tools.ImageProvider.java
/** * Creates a rotated version of the input image. * * @param c The component to get properties useful for painting, e.g. the foreground or * background color.//from w w w .j a v a2 s. com * @param img the image to be rotated. * @param rotatedAngle the rotated angle, in degree, clockwise. It could be any double but we * will mod it with 360 before using it. * * @return the image after rotating. */ public static Image createRotatedImage(Component c, Image img, double rotatedAngle) { // convert rotatedAngle to a value from 0 to 360 double originalAngle = rotatedAngle % 360; if (rotatedAngle != 0 && originalAngle == 0) { originalAngle = 360.0; } // convert originalAngle to a value from 0 to 90 double angle = originalAngle % 90; if (originalAngle != 0.0 && angle == 0.0) { angle = 90.0; } double radian = Math.toRadians(angle); new ImageIcon(img); // load completely int iw = img.getWidth(null); int ih = img.getHeight(null); int w; int h; if ((originalAngle >= 0 && originalAngle <= 90) || (originalAngle > 180 && originalAngle <= 270)) { w = (int) (iw * Math.sin(DEGREE_90 - radian) + ih * Math.sin(radian)); h = (int) (iw * Math.sin(radian) + ih * Math.sin(DEGREE_90 - radian)); } else { w = (int) (ih * Math.sin(DEGREE_90 - radian) + iw * Math.sin(radian)); h = (int) (ih * Math.sin(radian) + iw * Math.sin(DEGREE_90 - radian)); } BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics g = image.getGraphics(); Graphics2D g2d = (Graphics2D) g.create(); // calculate the center of the icon. int cx = iw / 2; int cy = ih / 2; // move the graphics center point to the center of the icon. g2d.translate(w / 2, h / 2); // rotate the graphics about the center point of the icon g2d.rotate(Math.toRadians(originalAngle)); g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2d.drawImage(img, -cx, -cy, c); g2d.dispose(); new ImageIcon(image); // load completely return image; }
From source file:com.jillesvangurp.geo.GeoGeometry.java
/** * Converts a circle to a polygon./*from w w w . j a va2 s .c o m*/ * This method does not behave very well very close to the poles because the math gets a little funny there. * * @param segments * number of segments the polygon should have. The higher this * number, the better of an approximation the polygon is for the * circle. * @param latitude latitude * @param longitude longitude * @param radius radius of the circle * @return a linestring polygon */ public static double[][] circle2polygon(int segments, double latitude, double longitude, double radius) { validate(latitude, longitude, false); if (segments < 5) { throw new IllegalArgumentException("you need a minimum of 5 segments"); } double[][] points = new double[segments + 1][0]; double relativeLatitude = radius / EARTH_RADIUS_METERS * 180 / PI; // things get funny near the north and south pole, so doing a modulo 90 // to ensure that the relative amount of degrees doesn't get too crazy. double relativeLongitude = relativeLatitude / cos(Math.toRadians(latitude)) % 90; for (int i = 0; i < segments; i++) { // radians go from 0 to 2*PI; we want to divide the circle in nice // segments double theta = 2 * PI * i / segments; // trying to avoid theta being exact factors of pi because that results in some funny behavior around the // north-pole theta = theta += 0.1; if (theta >= 2 * PI) { theta = theta - 2 * PI; } // on the unit circle, any point of the circle has the coordinate // cos(t),sin(t) where t is the radian. So, all we need to do that // is multiply that with the relative latitude and longitude // note, latitude takes the role of y, not x. By convention we // always note latitude, longitude instead of the other way around double latOnCircle = latitude + relativeLatitude * Math.sin(theta); double lonOnCircle = longitude + relativeLongitude * Math.cos(theta); if (lonOnCircle > 180) { lonOnCircle = -180 + (lonOnCircle - 180); } else if (lonOnCircle < -180) { lonOnCircle = 180 - (lonOnCircle + 180); } if (latOnCircle > 90) { latOnCircle = 90 - (latOnCircle - 90); } else if (latOnCircle < -90) { latOnCircle = -90 - (latOnCircle + 90); } points[i] = new double[] { lonOnCircle, latOnCircle }; } // should end with same point as the origin points[points.length - 1] = new double[] { points[0][0], points[0][1] }; return points; }
From source file:org.interpss.mapper.odm.impl.aclf.AclfBranchDataHelper.java
private void setXfr3WData(Xfr3WBranchXmlType xml3WXfr, Xfr3WAdapter xfr3W) throws InterpssException { Aclf3WXformer branch3W = (Aclf3WXformer) this.branch; double baseKva = aclfNet.getBaseKva(); // <magnitizingY unit="PU" im="-0.0042" re="0.0012"/> YXmlType fromShuntY = xml3WXfr.getMagnitizingY(); if (fromShuntY != null) { Complex ypu = UnitHelper.yConversion(new Complex(fromShuntY.getRe(), fromShuntY.getIm()), branch3W.getFromBus().getBaseVoltage(), baseKva, ToYUnit.f(fromShuntY.getUnit()), UnitType.PU); branch3W.getFromAclfBranch().setFromShuntY(ypu); }//w ww . j a v a 2 s . co m // <meterLocation>ToSide</meterLocation> double fromBaseV = branch3W.getFromBus().getBaseVoltage(), toBaseV = branch3W.getToBus().getBaseVoltage(), tertBaseV = branch3W.getToBus().getBaseVoltage(); // turn ratio is based on xfr rated voltage // voltage units should be same for both side double fromRatedV = fromBaseV; double toRatedV = toBaseV; double tertRatedV = tertBaseV; double zratio = 1.0; double tapratio = 1.0; Transformer3WInfoXmlType xfrData = (Transformer3WInfoXmlType) xml3WXfr.getXfrInfo(); /* <xfrInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Transformer3WInfoXmlType"> <dataOnSystemBase>true</dataOnSystemBase> <ratedPower unit="MVA" value="1000.0"/> <starVMag unit="PU" value="0.99004"/> <starVAng unit="DEG" value="1.5349"/> <ratedPower23 unit="MVA" value="1000.0"/> <ratedPower31 unit="MVA" value="1000.0"/> </xfrInfo> */ if (xfrData != null) { if (xfrData.getFromRatedVoltage() != null) fromRatedV = xfrData.getFromRatedVoltage().getValue(); if (xfrData.getToRatedVoltage() != null) toRatedV = xfrData.getToRatedVoltage().getValue(); if (xfrData.getTertRatedVoltage() != null) tertRatedV = xfrData.getTertRatedVoltage().getValue(); if (!xfrData.isDataOnSystemBase() && xfrData.getRatedPower() != null && xfrData.getRatedPower().getValue() > 0.0) zratio = xfrData.getRatedPower().getUnit() == ApparentPowerUnitType.KVA ? baseKva / xfrData.getRatedPower().getValue() : 0.001 * baseKva / xfrData.getRatedPower().getValue(); if (!xfrData.isDataOnSystemBase()) tapratio = (fromRatedV / fromBaseV) / (toRatedV / toBaseV); if (xfrData.getStarVMag() != null && xfrData.getStarVAng() != null) { if (xfrData.getStarVMag().getUnit() == VoltageUnitType.PU || xfrData.getStarVAng().getUnit() == AngleUnitType.DEG) { AclfBus starBus = (AclfBus) xfr3W.getAclf3WBranch().getStarBus(); starBus.setVoltage(xfrData.getStarVMag().getValue(), Math.toRadians(xfrData.getStarVAng().getValue())); xfr3W.getAclf3WBranch().setVoltageStarBus(starBus.getVoltage()); } else { throw new InterpssException("function not implemented yet"); } } } /* <z unit="PU" im="0.025" re="2.0E-4"/> <fromTurnRatio unit="PU" value="1.0101"/> <toTurnRatio unit="PU" value="1.05"/> <z23 unit="PU" im="0.01" re="3.0E-4"/> <z31 unit="PU" im="0.011" re="4.0E-4"/> <tertTurnRatio unit="PU" value="1.01"/> */ double baseV = fromBaseV > toBaseV ? fromBaseV : toBaseV; baseV = baseV > tertBaseV ? baseV : tertBaseV; Complex z12 = new Complex(xml3WXfr.getZ().getRe() * zratio, xml3WXfr.getZ().getIm() * zratio); Complex z23 = new Complex(xml3WXfr.getZ23().getRe() * zratio, xml3WXfr.getZ23().getIm() * zratio); Complex z31 = new Complex(xml3WXfr.getZ31().getRe() * zratio, xml3WXfr.getZ31().getIm() * zratio); UnitType unit = ToZUnit.f(xml3WXfr.getZ().getUnit()); // set 3W xfr branch z to the three 2W xfr branches xfr3W.setZ(z12, z31, z23, unit, baseV); double fromRatio = xml3WXfr.getFromTurnRatio().getValue() * tapratio; double toRatio = xml3WXfr.getToTurnRatio().getValue() * tapratio; double tertRatio = xml3WXfr.getTertTurnRatio().getValue() * tapratio; xfr3W.setFromTurnRatio(fromRatio == 0.0 ? 1.0 : fromRatio); xfr3W.setToTurnRatio(toRatio == 0.0 ? 1.0 : toRatio); xfr3W.setTertTurnRatio(tertRatio == 0.0 ? 1.0 : tertRatio); /* <ratingLimit> <mva unit="MVA" rating3="1090.0" rating2="1150.0" rating1="1200.0"/> </ratingLimit> <ratingLimit23> <mva unit="MVA" rating3="1112.0" rating2="1175.0" rating1="1250.0"/> </ratingLimit23> <ratingLimit13> <mva unit="MVA" rating3="1157.0" rating2="1200.0" rating1="1280.0"/> </ratingLimit13> */ }
From source file:EnvironmentExplorer.java
Box lightPanel() { Box panel = new Box(BoxLayout.Y_AXIS); // add the ambient light checkbox to the panel JCheckBox ambientCheckBox = new JCheckBox("Ambient Light"); ambientCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JCheckBox checkbox = (JCheckBox) e.getSource(); lightAmbient.setEnable(checkbox.isSelected()); }/*from ww w .j av a 2s. c o m*/ }); ambientCheckBox.setSelected(true); panel.add(new LeftAlignComponent(ambientCheckBox)); String[] lightTypeValues = { "None", "Directional", "Positional", "Spot" }; IntChooser lightTypeChooser = new IntChooser("Light Type:", lightTypeValues); lightTypeChooser.addIntListener(new IntListener() { public void intChanged(IntEvent event) { int value = event.getValue(); switch (value) { case 0: lightDirectional.setEnable(false); lightPoint.setEnable(false); lightSpot.setEnable(false); break; case 1: lightDirectional.setEnable(true); lightPoint.setEnable(false); lightSpot.setEnable(false); break; case 2: lightDirectional.setEnable(false); lightPoint.setEnable(true); lightSpot.setEnable(false); break; case 3: lightDirectional.setEnable(false); lightPoint.setEnable(false); lightSpot.setEnable(true); break; } } }); lightTypeChooser.setValueByName("Directional"); panel.add(lightTypeChooser); // Set up the sliders for the attenuation // top row panel.add(new LeftAlignComponent(new JLabel("Light attenuation:"))); FloatLabelJSlider constantSlider = new FloatLabelJSlider("Constant ", 0.1f, 0.0f, 3.0f, attenuation.x); constantSlider.setMajorTickSpacing(1.0f); constantSlider.setPaintTicks(true); constantSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.x = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(constantSlider); FloatLabelJSlider linearSlider = new FloatLabelJSlider("Linear ", 0.1f, 0.0f, 3.0f, attenuation.y); linearSlider.setMajorTickSpacing(1.0f); linearSlider.setPaintTicks(true); linearSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.y = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(linearSlider); FloatLabelJSlider quadradicSlider = new FloatLabelJSlider("Quadradic", 0.1f, 0.0f, 3.0f, attenuation.z); quadradicSlider.setMajorTickSpacing(1.0f); quadradicSlider.setPaintTicks(true); quadradicSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.z = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(quadradicSlider); // Set up the sliders for the attenuation // top row panel.add(new LeftAlignComponent(new JLabel("Spot light:"))); // spread angle is 0-180 degrees, no slider scaling FloatLabelJSlider spotSpreadSlider = new FloatLabelJSlider("Spread Angle ", 1.0f, 0.0f, 180.0f, spotSpreadAngle); spotSpreadSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { spotSpreadAngle = e.getValue(); lightSpot.setSpreadAngle((float) Math.toRadians(spotSpreadAngle)); } }); panel.add(spotSpreadSlider); // concentration angle is 0-128 degrees FloatLabelJSlider spotConcentrationSlider = new FloatLabelJSlider("Concentration", 1.0f, 0.0f, 128.0f, spotConcentration); spotConcentrationSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { spotConcentration = e.getValue(); lightSpot.setConcentration(spotConcentration); } }); panel.add(spotConcentrationSlider); return panel; }