Examples of LiteralValueNode


Examples of org.openquark.cal.valuenode.LiteralValueNode

            ValueNode oldValue = getValueNode();
            Integer newValue = new Integer(slider.getValue());

            TypeExpr typeExpr = getValueNode().getTypeExpr();
            replaceValueNode(new LiteralValueNode(newValue, typeExpr), true);

            label.setText(String.valueOf(slider.getValue()));
            label.setToolTipText(String.valueOf(slider.getValue()));

            updateDisplayedColour();
View Full Code Here

Examples of org.openquark.cal.valuenode.LiteralValueNode

            ValueNode returnVN = new ListOfCharValueNode(stringValue, getValueNode().getTypeExpr());
            replaceValueNode(returnVN, true);

        } else if (valueNode instanceof LiteralValueNode){
            ValueNode returnVN = new LiteralValueNode(stringValue, getValueNode().getTypeExpr());
            replaceValueNode(returnVN, true);

        } else {
            throw new IllegalStateException("This value node cannot be handled by the string editor: " + valueNode.getClass());
        }
View Full Code Here

Examples of org.openquark.cal.valuenode.LiteralValueNode

       
        Gem upFromToGem = gemFactory.makeFunctionalAgentGem(CAL_Prelude.Functions.upFromTo);
        gemGraph.addGem(upFromToGem);

        // Create a Value gem to represent a BigInteger (Prelude.Integer) value for the number 1.
        Gem oneGem = new ValueGem(new LiteralValueNode(BigInteger.valueOf(1), calServices.getPreludeTypeConstants().getIntegerType()));
           
        gemGraph.addGem(oneGem);
       
        gemGraph.connectGems(oneGem.getOutputPart(), upFromToGem.getInputPart(0));
       
View Full Code Here

Examples of org.openquark.cal.valuenode.LiteralValueNode

        Object newValueObj = integerValues
                                ? (Object) new Integer((int) newValue)
                                : (Object) new Double(newValue);

        TypeExpr typeExpr = getValueNode().getTypeExpr();
        replaceValueNode(new LiteralValueNode(newValueObj, typeExpr), true);

        notifyValueChanged(oldValue);
    }
View Full Code Here

Examples of org.openquark.cal.valuenode.LiteralValueNode

                ListOfCharValueNode charListValueNode = (ListOfCharValueNode)newValueNodeFromMap;
                char[] charListValueArray = charListValueNode.getStringValue().toCharArray();

                ArrayList<ValueNode> newListValue = new ArrayList<ValueNode>(charListValueArray.length);
                for (final char charListValue : charListValueArray) {
                    newListValue.add(new LiteralValueNode(Character.valueOf(charListValue), charType));
                }
               
                newValueNode = new ListValueNode(newListValue, typeConstants.getCharListType(), new LiteralValueNode(new Character('a'), charType));
                replaceValueNode(newValueNode, true);
                return;

            } else {
                newValueNode = (ListValueNode)newValueNodeFromMap;
View Full Code Here

Examples of org.openquark.cal.valuenode.LiteralValueNode

       
        if (typeExpr.sameType(typeConstants.getCharType())) {

            // The first char should be the char we want as the value.
            Character charVal = new Character(newVal.charAt(0));
            valueEntryPanel.replaceValueNode(new LiteralValueNode(charVal, typeExpr.copyTypeExpr()), true);
           
        } else if (typeExpr.sameType(typeConstants.getByteType())) {

            Double unRoundedVal = new Double(newVal);
            Byte byteVal = new Byte(unRoundedVal.byteValue());
            valueEntryPanel.replaceValueNode(new LiteralValueNode(byteVal, typeExpr.copyTypeExpr()), true);
     
        } else if (typeExpr.sameType(typeConstants.getShortType())) {

            Double unRoundedVal = new Double(newVal);
            Short shortVal = new Short(unRoundedVal.shortValue());
            valueEntryPanel.replaceValueNode(new LiteralValueNode(shortVal, typeExpr.copyTypeExpr()), true);
             
        } else if (typeExpr.sameType(typeConstants.getIntType())) {

            Double unRoundedVal = new Double(newVal);
            Integer integerVal = Integer.valueOf(unRoundedVal.intValue());
            valueEntryPanel.replaceValueNode(new LiteralValueNode(integerVal, typeExpr.copyTypeExpr()), true);

        } else if (typeExpr.sameType(typeConstants.getIntegerType())) {
           
            BigDecimal unRoundedVal = new BigDecimal(newVal);
            BigInteger bigIntegerVal;
           
            // Math.round uses a rounding strategy that BigDecimal does not provide, so we have to do
            // a little bit of fiddling to round in an equivalent fashion.
            if(unRoundedVal.signum() >= 0) {
                bigIntegerVal = unRoundedVal.setScale(0, BigDecimal.ROUND_HALF_UP).toBigInteger();
            } else {
                bigIntegerVal = unRoundedVal.setScale(0, BigDecimal.ROUND_HALF_DOWN).toBigInteger();
            }
           
            valueEntryPanel.replaceValueNode(new LiteralValueNode(bigIntegerVal, typeExpr.copyTypeExpr()), true);
       
        } else if (typeExpr.sameType(typeConstants.getDecimalType())) {

            BigDecimal decimalVal = new BigDecimal(newVal);
            valueEntryPanel.replaceValueNode(new LiteralValueNode(decimalVal, typeExpr.copyTypeExpr()), true);

        } else if (typeExpr.sameType(typeConstants.getLongType())) {

            Double unRoundedVal = new Double(newVal);
            Long longVal = new Long(unRoundedVal.longValue());
            valueEntryPanel.replaceValueNode(new LiteralValueNode(longVal, typeExpr.copyTypeExpr()), true);

        } else if (typeExpr.sameType(typeConstants.getFloatType())) {

            Float floatVal = new Float(newVal);
            valueEntryPanel.replaceValueNode(new LiteralValueNode(floatVal, typeExpr.copyTypeExpr()), true);

        } else if (typeExpr.sameType(typeConstants.getDoubleType())) {

            Double doubleVal = new Double(newVal);
            valueEntryPanel.replaceValueNode(new LiteralValueNode(doubleVal, typeExpr.copyTypeExpr()), true);

        } else if (typeExpr.sameType(typeConstants.getStringType())) {
           
            newVal = newVal.replace(ListOfCharValueNode.CHAR_RETURN_REPLACE, '\n');
            valueEntryPanel.replaceValueNode(new LiteralValueNode(newVal, typeExpr.copyTypeExpr()), true);
           
        } else if (typeExpr.sameType(typeConstants.getCharListType())) {

            // First, must replace the return replacement chars with return.
            newVal = newVal.replace(ListOfCharValueNode.CHAR_RETURN_REPLACE, '\n');
View Full Code Here

Examples of org.openquark.cal.valuenode.LiteralValueNode

        if (typeExpr.sameType(typeConstants.getByteType())) {

            Double unRoundedVal = new Double(getDisplayField().getText());
            Byte byteVal = new Byte((byte) Math.round(unRoundedVal.doubleValue()));

            returnVN = new LiteralValueNode(byteVal, getValueNode().getTypeExpr());
           
        } else if (typeExpr.sameType(typeConstants.getShortType())) {

            Double unRoundedVal = new Double(getDisplayField().getText());
            Short shortVal = new Short((short) Math.round(unRoundedVal.doubleValue()));

            returnVN = new LiteralValueNode(shortVal, getValueNode().getTypeExpr());
           
        } else if (typeExpr.sameType(typeConstants.getIntType())) {

            Double unRoundedVal = new Double(getDisplayField().getText());
            Integer integerVal = new Integer((int) Math.round(unRoundedVal.doubleValue()));

            returnVN = new LiteralValueNode(integerVal, getValueNode().getTypeExpr());                              
           
        } else if (typeExpr.sameType(typeConstants.getIntegerType())) {

            BigDecimal unRoundedVal = new BigDecimal(getDisplayField().getText());
           
            // Ridiculously, BigDecimal has 8 rounding modes, not one of which is equivalent
            // to the mode used by Math.round!  ROUND_HALF_CEILING is what such a mode would
            // be called if it existed; we can fake it out by using a different rounding mode
            // depending upon the sign of the unrounded value.
            BigInteger bigIntegerVal;
           
            if(unRoundedVal.signum() >= 0) {
                bigIntegerVal = unRoundedVal.setScale(0, BigDecimal.ROUND_HALF_UP).toBigInteger();
            } else {
                bigIntegerVal = unRoundedVal.setScale(0, BigDecimal.ROUND_HALF_DOWN).toBigInteger();
            }

            returnVN = new LiteralValueNode(bigIntegerVal, getValueNode().getTypeExpr());                              
       
        } else if (typeExpr.sameType(typeConstants.getDecimalType())) {

            BigDecimal decimalVal = new BigDecimal(getDisplayField().getText());
            returnVN = new LiteralValueNode(decimalVal, getValueNode().getTypeExpr());

        } else if (typeExpr.sameType(typeConstants.getLongType())) {

            Double unRoundedVal = new Double(getDisplayField().getText());
            Long longVal = new Long(Math.round(unRoundedVal.doubleValue()));

            returnVN = new LiteralValueNode(longVal, getValueNode().getTypeExpr());
           
        } else if (typeExpr.sameType(typeConstants.getFloatType())) {

            Float floatVal = new Float(getDisplayField().getText());
            returnVN = new LiteralValueNode(floatVal, getValueNode().getTypeExpr());

        } else if (typeExpr.sameType(typeConstants.getDoubleType())) {

            Double doubleVal = new Double(getDisplayField().getText());
            returnVN = new LiteralValueNode(doubleVal, getValueNode().getTypeExpr());
                       
        } else {
             throw new IllegalStateException("Error in NumberValueEditor close:\nCurrently cannot handle this type.");
        }
View Full Code Here

Examples of org.openquark.cal.valuenode.LiteralValueNode

            doubleVal = new Double("0.0");
        }

        // Configure the value format - the document for the display area.
        TypeExpr doubleType = TypeExpr.makeNonParametricType(valueEditorManager.getPerspective().getTypeConstructor(CAL_Prelude.TypeConstructors.Double));
        ValueNode doubleValueNode = new LiteralValueNode(doubleVal, doubleType);
       
        ValueFormat valueFormat = new ValueFormat(new ValueEntryPanel(valueEditorHierarchyManager, doubleValueNode));
        valueFormat.setChecking(true);

        // Configure the display area itself.
View Full Code Here

Examples of org.openquark.cal.valuenode.LiteralValueNode

        //       Probably should use the ValueNodeBuilderHelper.
       
        PreludeTypeConstants preludeTypeConstants = calServices.getPreludeTypeConstants();
       
        if (value instanceof Character) {
            return new LiteralValueNode(value, preludeTypeConstants.getCharType());
        }
        else if (value instanceof Boolean) {
            return new LiteralValueNode(value, preludeTypeConstants.getBooleanType());
        }
        else if (value instanceof Byte) {
            return new LiteralValueNode(value, preludeTypeConstants.getByteType());
        }
        else if (value instanceof Short) {
            return new LiteralValueNode(value, preludeTypeConstants.getShortType());
        }
        else if (value instanceof Integer) {
            return new LiteralValueNode(value, preludeTypeConstants.getIntType());
        }
        else if (value instanceof Long) {
            return new LiteralValueNode(value, preludeTypeConstants.getLongType());
        }
        else if (value instanceof Float) {
            return new LiteralValueNode(value, preludeTypeConstants.getFloatType());
        }
        else if (value instanceof Double) {
            return new LiteralValueNode(value, preludeTypeConstants.getDoubleType());
        }
        else if (value instanceof String) {
            return new LiteralValueNode(value, preludeTypeConstants.getStringType());
        }
        else if (value instanceof Color) {       
            TypeExpr colourType = calServices.getTypeFromQualifiedName(CAL_Color.TypeConstructors.Color);
            if (colourType == null) {
                return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.