當前位置: 首頁>>代碼示例>>Java>>正文


Java DoubleAttribute類代碼示例

本文整理匯總了Java中org.geomajas.layer.feature.attribute.DoubleAttribute的典型用法代碼示例。如果您正苦於以下問題:Java DoubleAttribute類的具體用法?Java DoubleAttribute怎麽用?Java DoubleAttribute使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DoubleAttribute類屬於org.geomajas.layer.feature.attribute包,在下文中一共展示了DoubleAttribute類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createAttributeWidget

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
@Override
public Widget createAttributeWidget(Feature feature, AttributeDescriptor descriptor) {
	Attribute<?> attributeValue = feature.getAttributes().get(descriptor.getName());

	Widget widget;
	if (attributeValue == null) {
		attributeValue = new Attribute<String>() {

			@Override
			public String getValue() {
				return "";
			}
		};
	}
	feature.getAttributes().put(descriptor.getName(), attributeValue);
	if (attributeValue != null && attributeValue.getValue() instanceof DoubleAttribute) {
		widget = createDoubleWidget((DoubleAttribute) attributeValue.getValue());
	} else {
		widget = super.createAttributeWidget(feature, descriptor);
	}

	return widget;
}
 
開發者ID:geomajas,項目名稱:geomajas-project-client-gwt2,代碼行數:24,代碼來源:MyAttributeWidgetFactory.java

示例2: getDefaultAttributeInstance1

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
public static ManyToOneAttribute getDefaultAttributeInstance1(Long id) {
	 Map<String, PrimitiveAttribute<?>> attributes = new HashMap<String, PrimitiveAttribute<?>>();
	attributes.put("textAttr", new StringAttribute("manyToOne-1"));
	attributes.put("booleanAttr", new BooleanAttribute(true));
	attributes.put("intAttr", new IntegerAttribute(100));
	attributes.put("floatAttr", new FloatAttribute(100.0f));
	attributes.put("doubleAttr", new DoubleAttribute(100.0));
	
	DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
	Date date;
	try {
		date = format.parse("01/01/2009");
	} catch (ParseException e) {
		date = new Date();
	}
	attributes.put("dateAttr", new DateAttribute(date));
	return new ManyToOneAttribute(new AssociationValue(new LongAttribute(id), attributes));
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:19,代碼來源:HibernateTestManyToOne.java

示例3: getDefaultAttributeInstance

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
public static ManyToOneAttribute getDefaultAttributeInstance(Long id) {
	DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
	Date date;
	try {
		date = format.parse("01/01/2009");
	} catch (ParseException e) {
		date = new Date();
	}
	Map<String, PrimitiveAttribute<?>> attributes = new HashMap<String, PrimitiveAttribute<?>>();
	attributes.put(PARAM_TEXT_ATTR, new StringAttribute("manyToOne-1"));
	attributes.put(PARAM_BOOLEAN_ATTR, new BooleanAttribute(true));
	attributes.put(PARAM_INT_ATTR, new IntegerAttribute(100));
	attributes.put(PARAM_FLOAT_ATTR, new FloatAttribute(100.0f));
	attributes.put(PARAM_DOUBLE_ATTR, new DoubleAttribute(100.0));
	attributes.put(PARAM_DATE_ATTR, new DateAttribute(date));

	return new ManyToOneAttribute(new AssociationValue(new LongAttribute(id), attributes));
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:19,代碼來源:ManyToOneProperty.java

示例4: setAttributes

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void setAttributes() throws Exception {
	Date date = new Date();
	Map<String, Attribute> attributes = new HashMap<String, Attribute>();
	attributes.put(PARAM_TEXT_ATTR, new StringAttribute("new name"));
	attributes.put(PARAM_INT_ATTR, new IntegerAttribute(5));
	attributes.put(PARAM_FLOAT_ATTR, new FloatAttribute(5.0f));
	attributes.put(PARAM_DOUBLE_ATTR, new DoubleAttribute(5.0));
	attributes.put(PARAM_BOOLEAN_ATTR, new BooleanAttribute(false));
	attributes.put(PARAM_DATE_ATTR, new DateAttribute(date));
	featureModel.setAttributes(feature1, attributes);
	Assert.assertEquals("new name", featureModel.getAttribute(feature1, PARAM_TEXT_ATTR).getValue());
	Assert.assertEquals(5, featureModel.getAttribute(feature1, PARAM_INT_ATTR).getValue());
	Assert.assertEquals(5.0f, featureModel.getAttribute(feature1, PARAM_FLOAT_ATTR).getValue());
	Assert.assertEquals(5.0, featureModel.getAttribute(feature1, PARAM_DOUBLE_ATTR).getValue());
	Assert.assertFalse((Boolean) featureModel.getAttribute(feature1, PARAM_BOOLEAN_ATTR).getValue());
	Assert.assertEquals(date, featureModel.getAttribute(feature1, PARAM_DATE_ATTR).getValue());
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:20,代碼來源:HibernateFeatureModelTest.java

示例5: setAttributes

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
@Test
@SuppressWarnings("rawtypes")
public void setAttributes() throws Exception {
	Date date = new Date();
	Map<String, Attribute> attributes = new HashMap<String, Attribute>();
	attributes.put(PARAM_TEXT_ATTR, new StringAttribute("new name"));
	attributes.put(PARAM_INT_ATTR, new IntegerAttribute(5));
	attributes.put(PARAM_FLOAT_ATTR, new FloatAttribute(5.0f));
	attributes.put(PARAM_DOUBLE_ATTR, new DoubleAttribute(5.0));
	attributes.put(PARAM_BOOLEAN_ATTR, new BooleanAttribute(false));
	attributes.put(PARAM_DATE_ATTR, new DateAttribute(date));
	featureModel.setAttributes(feature1, attributes);
	Assert.assertEquals("new name", featureModel.getAttribute(feature1, PARAM_TEXT_ATTR).getValue());
	Assert.assertEquals(5, featureModel.getAttribute(feature1, PARAM_INT_ATTR).getValue());
	Assert.assertEquals(5.0f, featureModel.getAttribute(feature1, PARAM_FLOAT_ATTR).getValue());
	Assert.assertEquals(5.0, featureModel.getAttribute(feature1, PARAM_DOUBLE_ATTR).getValue());
	Assert.assertFalse((Boolean) featureModel.getAttribute(feature1, PARAM_BOOLEAN_ATTR).getValue());
	Assert.assertEquals(date, featureModel.getAttribute(feature1, PARAM_DATE_ATTR).getValue());
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:20,代碼來源:SimpleFeatureModelTest.java

示例6: testPrimitiveAttributes

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
@Test
public void testPrimitiveAttributes() throws LayerException {
	Map<String, Attribute<?>> attributes = new HashMap<String, Attribute<?>>();
	FeatureBean bean = new FeatureBean();
	attributes.put("stringAttr", new StringAttribute("s1"));
	attributes.put("doubleAttr", new DoubleAttribute(1.23));
	attributes.put("longAttr", new LongAttribute(12L));
	attributes.put("floatAttr", new FloatAttribute(1.67F));
	attributes.put("shortAttr", new ShortAttribute((short) 6));
	attributes.put("urlAttr", new UrlAttribute("http://haha"));
	service.setAttributes(bean, layerBeans.getLayerInfo().getFeatureInfo(), new DummyMapper(), attributes);
	Assert.assertEquals("s1", bean.getStringAttr());
	Assert.assertEquals(1.23, bean.getDoubleAttr(), 0.0001);
	Assert.assertEquals(12L, bean.getLongAttr().longValue());
	Assert.assertEquals(1.67F, bean.getFloatAttr(), 0.0001);
	Assert.assertEquals(6, bean.getShortAttr().shortValue());
	Assert.assertEquals("http://haha", bean.getUrlAttr());
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:19,代碼來源:EntityAttributeServiceTest.java

示例7: setDoubleAttribute

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
/**
 * Set attribute value of given type.
 *
 * @param name attribute name
 * @param value attribute value
 */
public void setDoubleAttribute(String name, Double value) {
	Attribute attribute = getAttributes().get(name);
	if (!(attribute instanceof DoubleAttribute)) {
		throw new IllegalStateException("Cannot set double value on attribute with different type, " +
				attribute.getClass().getName() + " setting value " + value);
	}
	((DoubleAttribute) attribute).setValue(value);
}
 
開發者ID:geomajas,項目名稱:geomajas-project-client-gwt,代碼行數:15,代碼來源:Feature.java

示例8: setValue

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
/**
 * Apply a double attribute value on the form, with the given name.
 *
 * @param name attribute name
 * @param attribute attribute value
 * @since 1.11.1
 */
@Api
public void setValue(String name, DoubleAttribute attribute) {
	FormItem item = formWidget.getField(name);
	if (item != null) {
		item.setValue(attribute.getValue());
	}
}
 
開發者ID:geomajas,項目名稱:geomajas-project-client-gwt,代碼行數:15,代碼來源:DefaultFeatureForm.java

示例9: getAttributeValue

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
Object getAttributeValue(Attribute attribute) {
	if (attribute instanceof PrimitiveAttribute<?>) {
		PrimitiveAttribute<?> p = (PrimitiveAttribute<?>) attribute;
		switch (p.getType()) {
			case BOOLEAN:
				return ((BooleanAttribute) p).getValue();
			case SHORT:
				return ((ShortAttribute) p).getValue();
			case INTEGER:
				return ((IntegerAttribute) p).getValue();
			case LONG:
				return ((LongAttribute) p).getValue();
			case FLOAT:
				return ((FloatAttribute) p).getValue();
			case DOUBLE:
				return ((DoubleAttribute) p).getValue();
			case CURRENCY:
				return ((CurrencyAttribute) p).getValue();
			case STRING:
				return ((StringAttribute) p).getValue();
			case DATE:
				return ((DateAttribute) p).getValue();
			case URL:
				return ((UrlAttribute) p).getValue();
			case IMGURL:
				return ((ImageUrlAttribute) p).getValue();
		}
		throw new IllegalArgumentException("Unknown primitive in test");
	} else {
		throw new IllegalArgumentException("Non primitives not supported by test");
	}
}
 
開發者ID:geomajas,項目名稱:geomajas-project-client-gwt,代碼行數:33,代碼來源:GwtTestDefaultAttributeFormFactory.java

示例10: newAttribute

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
Attribute newAttribute() {
	if (attribute instanceof PrimitiveAttribute<?>) {
		PrimitiveAttribute<?> p = (PrimitiveAttribute<?>) attribute;
		switch (p.getType()) {
			case BOOLEAN:
				return new BooleanAttribute();
			case SHORT:
				return new ShortAttribute();
			case INTEGER:
				return new IntegerAttribute();
			case LONG:
				return new LongAttribute();
			case FLOAT:
				return new FloatAttribute();
			case DOUBLE:
				return new DoubleAttribute();
			case CURRENCY:
				return new CurrencyAttribute();
			case STRING:
				return new StringAttribute();
			case DATE:
				return new DateAttribute();
			case URL:
				return new UrlAttribute();
			case IMGURL:
				return new ImageUrlAttribute();
		}
		throw new IllegalArgumentException("Unknown primtive in test");
	} else {
		throw new IllegalArgumentException("Non primitives not supported by test");
	}
}
 
開發者ID:geomajas,項目名稱:geomajas-project-client-gwt,代碼行數:33,代碼來源:GwtTestDefaultAttributeFormFactory.java

示例11: setAttributes

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void setAttributes() throws Exception {
	Map<String, Attribute> map = new HashMap<String, Attribute>();
	map.put(ATTRIBUTE_NAME, new StringAttribute("Heikant"));
	map.put(ATTRIBUTE_POPULATION, new DoubleAttribute(100.0));
	featureModel.setAttributes(feature, map);
	Assert.assertEquals("Heikant", featureModel.getAttribute(feature, ATTRIBUTE_NAME).getValue());
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:10,代碼來源:ShapeInMemFeatureModelTest.java

示例12: setNullAttributes

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
@Test
@SuppressWarnings("rawtypes")
public void setNullAttributes() throws Exception {
	Date date = new Date();
	Map<String, Attribute> attributes = new HashMap<String, Attribute>();
	attributes.put(PARAM_TEXT_ATTR, null);
	attributes.put(PARAM_INT_ATTR, null);
	attributes.put(PARAM_FLOAT_ATTR, null);
	attributes.put(PARAM_DOUBLE_ATTR, null);
	attributes.put(PARAM_BOOLEAN_ATTR, null);
	attributes.put(PARAM_DATE_ATTR, null);
	featureModel.setAttributes(feature1, attributes);
	Assert.assertNull(featureModel.getAttribute(feature1, PARAM_TEXT_ATTR).getValue());
	Assert.assertNull(featureModel.getAttribute(feature1, PARAM_INT_ATTR).getValue());
	Assert.assertNull(featureModel.getAttribute(feature1, PARAM_FLOAT_ATTR).getValue());
	Assert.assertNull(featureModel.getAttribute(feature1, PARAM_DOUBLE_ATTR).getValue());
	Assert.assertNull(featureModel.getAttribute(feature1, PARAM_BOOLEAN_ATTR).getValue());
	Assert.assertNull(featureModel.getAttribute(feature1, PARAM_DATE_ATTR).getValue());

	attributes.put(PARAM_TEXT_ATTR, new StringAttribute("new name"));
	attributes.put(PARAM_INT_ATTR, new IntegerAttribute(5));
	attributes.put(PARAM_FLOAT_ATTR, new FloatAttribute(5.0f));
	attributes.put(PARAM_DOUBLE_ATTR, new DoubleAttribute(5.0));
	attributes.put(PARAM_BOOLEAN_ATTR, new BooleanAttribute(false));
	attributes.put(PARAM_DATE_ATTR, new DateAttribute(date));
	featureModel.setAttributes(feature1, attributes);
	Assert.assertEquals("new name", featureModel.getAttribute(feature1, PARAM_TEXT_ATTR).getValue());
	Assert.assertEquals(5, featureModel.getAttribute(feature1, PARAM_INT_ATTR).getValue());
	Assert.assertEquals(5.0f, featureModel.getAttribute(feature1, PARAM_FLOAT_ATTR).getValue());
	Assert.assertEquals(5.0, featureModel.getAttribute(feature1, PARAM_DOUBLE_ATTR).getValue());
	Assert.assertFalse((Boolean) featureModel.getAttribute(feature1, PARAM_BOOLEAN_ATTR).getValue());
	Assert.assertEquals(date, featureModel.getAttribute(feature1, PARAM_DATE_ATTR).getValue());
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:34,代碼來源:SimpleFeatureModelTest.java

示例13: toPrimitiveDto

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
private Attribute<?> toPrimitiveDto(Object value, PrimitiveAttributeInfo info) {
	switch (info.getType()) {
		case BOOLEAN:
			return new BooleanAttribute((Boolean) convertToClass(value, Boolean.class));
		case SHORT:
			return new ShortAttribute((Short) convertToClass(value, Short.class));
		case INTEGER:
			return new IntegerAttribute((Integer) convertToClass(value, Integer.class));
		case LONG:
			return new LongAttribute((Long) convertToClass(value, Long.class));
		case FLOAT:
			return new FloatAttribute((Float) convertToClass(value, Float.class));
		case DOUBLE:
			return new DoubleAttribute((Double) convertToClass(value, Double.class));
		case CURRENCY:
			return new CurrencyAttribute((String) convertToClass(value, String.class));
		case STRING:
			return new StringAttribute(value == null ? null : value.toString());
		case DATE:
			return new DateAttribute((Date) value);
		case URL:
			return new UrlAttribute((String) value);
		case IMGURL:
			return new ImageUrlAttribute((String) value);
		default:
			throw new IllegalArgumentException("Cannot create primitive attribute of type " + info);
	}
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:29,代碼來源:DtoConverterServiceImpl.java

示例14: fromForm

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
@Override
public void fromForm(String name, Attribute<?> attribute) {
	AbstractReadOnlyAttributeInfo info = attributeInfoMap.get(name);
	if (null == attribute || null == info || !isIncluded(info) || !(info instanceof EditableAttributeInfo)) {
		return;
	}
	if (info instanceof PrimitiveAttributeInfo) {
		PrimitiveAttribute<?> primitive = (PrimitiveAttribute<?>) attribute;
		switch (primitive.getType()) {
			case BOOLEAN:
				getValue(name, (BooleanAttribute) primitive); // NOSONAR valid cast
				break;
			case SHORT:
				getValue(name, (ShortAttribute) primitive); // NOSONAR valid cast
				break;
			case INTEGER:
				getValue(name, (IntegerAttribute) primitive); // NOSONAR valid cast
				break;
			case LONG:
				getValue(name, (LongAttribute) primitive); // NOSONAR valid cast
				break;
			case FLOAT:
				getValue(name, (FloatAttribute) primitive); // NOSONAR valid cast
				break;
			case DOUBLE:
				getValue(name, (DoubleAttribute) primitive); // NOSONAR valid cast
				break;
			case CURRENCY:
				getValue(name, (CurrencyAttribute) primitive); // NOSONAR valid cast
				break;
			case STRING:
				getValue(name, (StringAttribute) primitive); // NOSONAR valid cast
				break;
			case URL:
				getValue(name, (UrlAttribute) primitive); // NOSONAR valid cast
				break;
			case IMGURL:
				getValue(name, (ImageUrlAttribute) primitive); // NOSONAR valid cast
				break;
			case DATE:
				getValue(name, (DateAttribute) primitive); // NOSONAR valid cast
				break;
			default:
				throw new IllegalStateException("Unhandled primitive attribute type " +
						primitive.getType());
		}
	} else {
		AssociationAttribute<?> association = (AssociationAttribute<?>) attribute;
		FormItem item = formWidget.getItem(name);
		Object associationItem = item.getAttributeAsObject(AssociationItem.ASSOCIATION_ITEM_ATTRIBUTE_KEY);
		switch (association.getType()) {
			case MANY_TO_ONE:
				((ManyToOneItem<?>) associationItem).fromItem((ManyToOneAttribute) attribute); // NOSONAR valid cast
				break;
			case ONE_TO_MANY:
				((OneToManyItem<?>) associationItem).fromItem((OneToManyAttribute) attribute); // NOSONAR valid cast
				break;
			default:
				throw new IllegalStateException("Unhandled association attribute type " +
						association.getType());
		}
	}
}
 
開發者ID:geomajas,項目名稱:geomajas-project-client-gwt,代碼行數:64,代碼來源:DefaultFeatureForm.java

示例15: AttributeInfoPair

import org.geomajas.layer.feature.attribute.DoubleAttribute; //導入依賴的package包/類
AttributeInfoPair(String name, String label, double value) {
	this.attribute = new DoubleAttribute(value);
	this.info = new PrimitiveAttributeInfo(name, label, PrimitiveType.DOUBLE);
}
 
開發者ID:geomajas,項目名稱:geomajas-project-client-gwt,代碼行數:5,代碼來源:GwtTestDefaultAttributeFormFactory.java


注:本文中的org.geomajas.layer.feature.attribute.DoubleAttribute類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。