本文整理汇总了Java中javax.measure.quantity.Dimensionless类的典型用法代码示例。如果您正苦于以下问题:Java Dimensionless类的具体用法?Java Dimensionless怎么用?Java Dimensionless使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Dimensionless类属于javax.measure.quantity包,在下文中一共展示了Dimensionless类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDescriptorFor
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Override
public MetricDescriptor getDescriptorFor(final String metricName) {
return new MetricDescriptor() {
@Override
public Unit<Dimensionless> getUnit() {
return ONE;
}
@Override
public String getDescription() {
return metricName;
}
@Override
public ValueSemantics getSemantics() {
return ValueSemantics.FREE_RUNNING;
}
};
}
开发者ID:performancecopilot,项目名称:parfait,代码行数:20,代码来源:DefaultMetricDescriptorLookup.java
示例2: getCreate
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
private static List<IOperation> getCreate()
{
List<IOperation> create = new ArrayList<IOperation>();
create.add(new AddLayerOperation());
create
.add(new CreateSingletonGenerator("dimensionless", Dimensionless.UNIT));
create.add(new CreateSingletonGenerator("frequency", HERTZ
.asType(Frequency.class)));
create.add(new CreateSingletonGenerator("decibels", NonSI.DECIBEL));
create.add(new CreateSingletonGenerator("speed (m/s)", METRE.divide(SECOND)
.asType(Velocity.class)));
create.add(new CreateSingletonGenerator("course (degs)",
SampleData.DEGREE_ANGLE.asType(Angle.class)));
create.add(new CreateSingletonGenerator("time (secs)",
SI.SECOND.asType(Duration.class)));
// create.add(new CreateLocationAction());
create.add(new GenerateGrid());
return create;
}
开发者ID:debrief,项目名称:limpet,代码行数:27,代码来源:OperationsLibrary.java
示例3: areFunctionallyIdenticalUnits
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
private static boolean areFunctionallyIdenticalUnits(Unit<?> left, Unit<?> right) {
if (!left.isCompatible(right)) {
return false;
}
Unit<?> divided = left.divide(right);
if (!divided.getDimension().equals(Dimension.NONE)) {
return false;
}
return divided.asType(Dimensionless.class).getConverterTo(ONE).equals(IDENTITY);
}
开发者ID:performancecopilot,项目名称:parfait,代码行数:11,代码来源:UnitMapping.java
示例4: getDimension
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
public Dimension getDimension(BaseUnit<?> unit) {
if (unit.equals(SI.METRE)) return Dimension.LENGTH;
if (unit.equals(SI.KILOGRAM)) return Dimension.MASS;
if (unit.equals(SI.KELVIN)) return Dimension.TEMPERATURE;
if (unit.equals(SI.SECOND)) return Dimension.TIME;
if (unit.equals(SI.AMPERE)) return Dimension.ELECTRIC_CURRENT;
if (unit.equals(SI.MOLE)) return Dimension.AMOUNT_OF_SUBSTANCE;
if (unit.equals(SI.CANDELA)) return SI.WATT.getDimension();
return new Dimension(new BaseUnit<Dimensionless>("[" + unit.getSymbol() + "]"));
}
开发者ID:jgaltidor,项目名称:VarJ,代码行数:11,代码来源:Dimension.java
示例5: getY
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Override
public Amount<QY> getY(Amount<QX> xValue) {
/* cast is safe since x and inverseExpConst are the same Dimension */
@SuppressWarnings("unchecked")
Amount<Dimensionless> divisionResult = (Amount<Dimensionless>) xValue.divide(inverseExpConst);
return amplitude.times(Math.exp(divisionResult.doubleValue(ONE)));
}
开发者ID:tensorics,项目名称:tensorics-core,代码行数:8,代码来源:ExponentialFunction.java
示例6: test
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Test
public void test() {
Amount<ElectricCurrent> current1 = Amount.valueOf(12, AMPERE);
Amount<ElectricCurrent> current2 = Amount.valueOf(2, AMPERE);
@SuppressWarnings("unchecked")
Amount<Dimensionless> result = (Amount<Dimensionless>) current1.divide(current2);
assertNotNull(result);
System.out.println(result.getUnit());
System.out.println(result.doubleValue(ONE));
}
开发者ID:tensorics,项目名称:tensorics-core,代码行数:13,代码来源:ExponentialFunctionTest.java
示例7: isDecibels
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
/**
* special case. Once a decibels unit has been restored from file, the equals comparison no longer
* works. So, we've copied the below content from the original sources. The original sources also
* includes a comparison of db.converter, but we've omitted that, since it's not visible. If we
* start getting false positives, we'll have to consider using the derived converter object.
*
* @param that
* object we're considering
* @return if it's the units of decibels
*/
private boolean isDecibels(Object that)
{
final TransformedUnit<Dimensionless> db =
(TransformedUnit<Dimensionless>) NonSI.DECIBEL;
if (this == that)
return true;
if (!(that instanceof TransformedUnit))
return false;
TransformedUnit<?> thatUnit = (TransformedUnit<?>) that;
return db.getParentUnit().equals(thatUnit.getParentUnit());
}
开发者ID:debrief,项目名称:limpet,代码行数:22,代码来源:LimpetLabelProvider.java
示例8: NumberDocument
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
public NumberDocument(final DoubleDataset dataset,
final ICommand predecessor, final Unit<?> qType)
{
super(dataset, predecessor);
if (qType == null)
{
this.qType = Dimensionless.UNIT;
}
else
{
this.qType = qType;
}
}
开发者ID:debrief,项目名称:limpet,代码行数:15,代码来源:NumberDocument.java
示例9: BurnSummary
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
public BurnSummary(Burn b) {
for (Interval i : b.getData().values()) {
ns = ns.plus(i.dt.times(i.thrust));
if (i.thrust.isGreaterThan(Amount.valueOf(0.01, SI.NEWTON))) {
thrustTime = thrustTime.plus(i.dt);
}
if (i.thrust.isGreaterThan(maxThrust))
maxThrust = i.thrust;
if (i.chamberPressure.isGreaterThan(maxPressure))
maxPressure = i.chamberPressure;
}
isp = ns
.divide(b
.getMotor()
.getGrain()
.volume(Amount.valueOf(0, SI.MILLIMETER))
.times(b.getMotor()
.getFuel()
.getIdealDensity()
.times(b.getMotor().getFuel()
.getDensityRatio())))
.to(SI.METERS_PER_SECOND)
.divide(Amount.valueOf(9.81,
SI.METERS_PER_SQUARE_SECOND)).to(SI.SECOND);
if ( b.getMotor().getChamber().getBurstPressure() != null )
saftyFactor = b.getMotor().getChamber().getBurstPressure().divide(maxPressure).to(Dimensionless.UNIT).doubleValue(Dimensionless.UNIT);
Amount<Volume> vol = b.getMotor().getGrain().volume(Amount.valueOf(0, SI.MILLIMETER));
Amount<VolumetricDensity> ideal = b.getMotor().getFuel().getIdealDensity();
Amount<VolumetricDensity> actual = ideal.times(b.getMotor().getFuel().getDensityRatio());
propellantMass = vol.times(actual).to(SI.GRAM);
Amount<Volume> chamber = b.getMotor().getChamber().chamberVolume();
volumeLoading = vol.divide(chamber).to(Dimensionless.UNIT).doubleValue(Dimensionless.UNIT);
}
开发者ID:bkuker,项目名称:motorsim,代码行数:38,代码来源:BurnSummary.java
示例10: burnRate
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Override
public Amount<Velocity> burnRate(final Amount<Pressure> pressure) {
if ( pressure.isLessThan(ZERO_PRESSURE) )
return ZERO_VELOCITY;
if ( entries.size() == 1 ){
return entries.get(entries.firstKey()).burnRate;
}
if ( entries.containsKey(pressure) ){
return entries.get(pressure).burnRate;
}
Entry low = null;
low = entries.get(entries.headMap(pressure).lastKey());
Entry high = null;
try {
high = entries.get(entries.tailMap(pressure).firstKey());
} catch ( NoSuchElementException e ){
log.warn("Pressure " + pressure + " is outside of expiermental range for " + this.getName());
high = low;
low = entries.get(entries.headMap(low.pressure).lastKey());
}
Amount<Pressure> lowToHigh = high.pressure.minus(low.pressure);
Amount<Pressure> lowToTarget = pressure.minus(low.pressure);
Amount<Dimensionless> frac = lowToTarget.divide(lowToHigh).to(Dimensionless.UNIT);
Amount<Velocity> vdiff = high.burnRate.minus(low.burnRate);
Amount<Velocity> ret = low.burnRate.plus(vdiff.times(frac));
if ( ret.isLessThan(ZERO_VELOCITY) )
return ZERO_VELOCITY;
return ret;
}
开发者ID:bkuker,项目名称:motorsim,代码行数:38,代码来源:EditablePiecewiseLinearFuel.java
示例11: UnitScale
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
private UnitScale(int pmUnitsValue, Unit<Dimensionless> unit) {
this.pmUnitsValue = pmUnitsValue;
this.unit = unit;
}
开发者ID:performancecopilot,项目名称:parfait,代码行数:5,代码来源:PcpScale.java
示例12: getUnit
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Override
public Unit<Dimensionless> getUnit() {
return unit;
}
开发者ID:performancecopilot,项目名称:parfait,代码行数:5,代码来源:PcpScale.java
示例13: getUnaryOutputUnit
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Override
protected Unit<?> getUnaryOutputUnit(final Unit<?> first)
{
return Dimensionless.UNIT;
}
开发者ID:debrief,项目名称:limpet,代码行数:6,代码来源:TestArithmeticCollections.java
示例14: testCreateSingletonGenerator
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Test
public void testCreateSingletonGenerator()
{
StoreGroup store = new SampleData().getData(10);
CreateSingletonGenerator generator =
new CreateSingletonGenerator("dimensionless", Dimensionless.UNIT);
assertNotNull("Create Single Generator is not NULL", generator);
List<IStoreItem> selection = new ArrayList<IStoreItem>();
StoreGroup storeGroup = new StoreGroup("Track 1");
selection.add(storeGroup);
IContext mockContext = EasyMock.createMock(MockContext.class);
Collection<ICommand> singleGeneratorActionFor =
generator.actionsFor(selection, store, mockContext);
assertEquals("Create location collection size", 1, singleGeneratorActionFor
.size());
ICommand singleGenCommand = singleGeneratorActionFor.iterator().next();
final String outName = "new_name";
EasyMock.expect(
mockContext.getInput("New variable", "Enter name for variable", "new dimensionless"))
.andReturn(outName).times(1);
EasyMock.expect(
mockContext.getInput("New variable",
"Enter initial value for variable", "100")).andReturn("1234.56")
.times(1);
EasyMock.expect(
mockContext.getInput("New variable",
"Enter the range for variable (or cancel to leave un-ranged)", "0:100")).andReturn("5:100")
.times(1);
EasyMock.replay(mockContext);
singleGenCommand.execute();
NumberDocument output = (NumberDocument) singleGenCommand.getOutputs().get(0);
assertNotNull(output);
assertEquals("correct name", outName, output.getName());
assertEquals("correct size", 1, output.size());
assertEquals("correct value", 1234.56, output.getValueAt(0), 0.01);
assertEquals("correct range", new Range(5d,100d), output.getRange());
assertEquals("correct units", Dimensionless.UNIT, output.getUnits());
assertEquals("no index units", null, output.getIndexUnits());
assertFalse("not indexed", output.isIndexed());
assertTrue("is quantity", output.isQuantity());
}
开发者ID:debrief,项目名称:limpet,代码行数:48,代码来源:TestOperations.java
示例15: testCreateSingletonGeneratorInvalid
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Test
public void testCreateSingletonGeneratorInvalid()
{
StoreGroup store = new SampleData().getData(10);
CreateSingletonGenerator generator =
new CreateSingletonGenerator("dimensionless", Dimensionless.UNIT);
assertNotNull("Create Single Generator is not NULL", generator);
List<IStoreItem> selection = new ArrayList<IStoreItem>();
StoreGroup storeGroup = new StoreGroup("Track 1");
selection.add(storeGroup);
IContext mockContext = EasyMock.createMock(MockContext.class);
Collection<ICommand> singleGeneratorActionFor =
generator.actionsFor(selection, store, mockContext);
assertEquals("Create location collection size", 1, singleGeneratorActionFor
.size());
ICommand singleGenCommand = singleGeneratorActionFor.iterator().next();
final String outName = "new_name";
EasyMock.expect(
mockContext.getInput("New variable", "Enter name for variable", "new dimensionless"))
.andReturn(outName).times(1);
EasyMock.expect(
mockContext.getInput("New variable",
"Enter initial value for variable", "100")).andReturn("1234.56")
.times(1);
EasyMock.expect(
mockContext.getInput("New variable",
"Enter the range for variable (or cancel to leave un-ranged)", "0:100")).andReturn("")
.times(1);
EasyMock.replay(mockContext);
singleGenCommand.execute();
NumberDocument output = (NumberDocument) singleGenCommand.getOutputs().get(0);
assertNotNull(output);
assertEquals("correct name", outName, output.getName());
assertEquals("correct size", 1, output.size());
assertEquals("correct value", 1234.56, output.getValueAt(0), 0.01);
assertEquals("correct range", null, output.getRange());
}
开发者ID:debrief,项目名称:limpet,代码行数:44,代码来源:TestOperations.java
示例16: testNonTimeIndex
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Test
public void testNonTimeIndex() throws Exception
{
File file = getDataFile("non_time/BalloonAscentData.csv");
assertTrue(file.isFile());
final String absPath = file.getAbsolutePath();
List<IStoreItem> items = new CsvParser().parse(absPath);
assertEquals("correct group", 1, items.size());
StoreGroup group = (StoreGroup) items.get(0);
assertEquals("correct num collections", 9, group.size());
IDocument<?> firstColl = (IDocument<?>) group.get(0);
assertEquals("correct num rows", 185, firstColl.size());
// check we have the correct data types
int ctr = 0;
NumberDocument thisN = (NumberDocument) group.get(ctr++);
assertTrue("correct data type", thisN instanceof NumberDocument);
assertEquals("correct units", SECOND, thisN.getUnits());
assertEquals("correct name", "BalloonAscentData-Time", thisN.getName());
assertEquals("correct index units", METER, thisN.getIndexUnits());
thisN = (NumberDocument) group.get(ctr++);
assertTrue("correct data type", thisN instanceof NumberDocument);
assertEquals("correct units",MILLI(BAR).asType(
Pressure.class), thisN.getUnits());
assertEquals("correct name", "BalloonAscentData-Pressure", thisN.getName());
assertEquals("correct index units", METER, thisN.getIndexUnits());
thisN = (NumberDocument) group.get(ctr++);
assertTrue("correct data type", thisN instanceof NumberDocument);
assertEquals("correct units",CELSIUS, thisN.getUnits());
assertEquals("correct name", "BalloonAscentData-Air Temperature", thisN.getName());
assertEquals("correct index units", METER, thisN.getIndexUnits());
thisN = (NumberDocument) group.get(ctr++);
assertTrue("correct data type", thisN instanceof NumberDocument);
assertEquals("correct units",CELSIUS, thisN.getUnits());
assertEquals("correct name", "BalloonAscentData-Dewpoint", thisN.getName());
assertEquals("correct index units", METER, thisN.getIndexUnits());
thisN = (NumberDocument) group.get(ctr++);
assertTrue("correct data type", thisN instanceof NumberDocument);
assertEquals("correct units",GRAM
.divide(CENTI(METER).pow(3)).asType(VolumetricDensity.class), thisN.getUnits());
assertEquals("correct name", "BalloonAscentData-Water density", thisN.getName());
assertEquals("correct index units", METER, thisN.getIndexUnits());
thisN = (NumberDocument) group.get(ctr++);
assertTrue("correct data type", thisN instanceof NumberDocument);
assertEquals("correct units",Dimensionless.UNIT, thisN.getUnits());
assertEquals("correct name", "BalloonAscentData-Humidity", thisN.getName());
assertEquals("correct index units", METER, thisN.getIndexUnits());
thisN = (NumberDocument) group.get(ctr++);
assertTrue("correct data type", thisN instanceof NumberDocument);
assertEquals("correct units",METRE.divide(SECOND).asType(
Velocity.class), thisN.getUnits());
assertEquals("correct name", "BalloonAscentData-Wind speed", thisN.getName());
assertEquals("correct index units", METER, thisN.getIndexUnits());
thisN = (NumberDocument) group.get(ctr++);
assertTrue("correct data type", thisN instanceof NumberDocument);
assertEquals("correct units",SampleData.DEGREE_ANGLE
.asType(Angle.class), thisN.getUnits());
assertEquals("correct name", "BalloonAscentData-Wind direction", thisN.getName());
assertEquals("correct index units", METER, thisN.getIndexUnits());
StringDocument thisS = (StringDocument) group.get(8);
assertTrue("correct data type", thisS instanceof StringDocument);
assertEquals("correct index units", METER, thisS.getIndexUnits());
}
开发者ID:debrief,项目名称:limpet,代码行数:72,代码来源:TestCsvParser.java
示例17: getAdmin
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
private static List<IOperation> getAdmin()
{
List<IOperation> admin = new ArrayList<IOperation>();
admin.add(new GenerateDummyDataOperation("small", 20));
admin.add(new GenerateDummyDataOperation("large", 1000));
admin.add(new GenerateDummyDataOperation("monster", 1000000));
admin.add(new CreateNewIndexedDatafileOperation());
admin.add(new CreateNewLookupDatafileOperation());
admin.add(new UnaryQuantityOperation("Clear units")
{
@Override
protected boolean appliesTo(List<IStoreItem> selection)
{
return true;
}
@Override
protected Unit<?> getUnaryOutputUnit(Unit<?> first)
{
return Dimensionless.UNIT;
}
@Override
protected String getUnaryNameFor(String name)
{
return "Clear units";
}
@Override
public Dataset calculate(Dataset input)
{
throw new RuntimeException("Not implemented");
}
});
// and the export operations
admin.add(new ExportCsvToFileAction());
admin.add(new CopyCsvToClipboardAction());
return admin;
}
开发者ID:debrief,项目名称:limpet,代码行数:42,代码来源:OperationsLibrary.java
示例18: createImporters
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
private void createImporters()
{
if (_candidates != null)
{
return;
}
_candidates = new ArrayList<DataImporter>();
_candidates.add(new AbsoluteLocationImporter());
_candidates.add(new RelativeLocationImporter());
_candidates.add(new TemporalSeriesSupporter(SECOND.asType(Duration.class),
null, new String[]
{"secs", "s"}));
_candidates.add(new TemporalSeriesSupporter(MILLI(SECOND).asType(
Duration.class), null, "ms"));
_candidates.add(new TemporalSeriesSupporter(HERTZ.asType(Frequency.class),
null, "Hz"));
_candidates.add(new TemporalSeriesSupporter(SampleData.DEGREE_ANGLE.divide(
SECOND).asType(AngularVelocity.class), null, "Degs/sec"));
_candidates.add(new TemporalSeriesSupporter(METRE.asType(Length.class),
null, "m"));
_candidates.add(new TemporalSeriesSupporter(MILLI(BAR).asType(
Pressure.class), null, new String[]
{"mb", "millibars"}));
_candidates.add(new TemporalSeriesSupporter(YARD.asType(Length.class),
null, "yds"));
_candidates.add(new TemporalSeriesSupporter(SampleData.DEGREE_ANGLE
.asType(Angle.class), null, new String[]
{"Degs", "Degr", "Deg"}));
_candidates.add(new TemporalSeriesSupporter(GRAM
.divide(CENTI(METER).pow(3)).asType(VolumetricDensity.class), null,
new String[]
{"g/cm3", "g/cm"}));
_candidates.add(new TemporalSeriesSupporter(NAUTICAL_MILE.divide(
SECOND.times(3600)).asType(Velocity.class), null, "kts"));
_candidates.add(new TemporalSeriesSupporter(NonSI.MILE.divide(
SI.SECOND.times(60 * 60)).asType(Velocity.class), null, new String[]
{"mph"}));
_candidates.add(new TemporalSeriesSupporter(NonSI.REVOLUTION.divide(SECOND
.times(60)), null, new String[]
{"rpm"}));
_candidates.add(new TemporalSeriesSupporter(METRE.divide(SECOND).asType(
Velocity.class), null, new String[]
{"M/Sec", "m/s"}));
_candidates.add(new TemporalSeriesSupporter(SI.CELSIUS
.asType(Temperature.class), null, new String[]
{"C", "DegC"}));
_candidates.add(new TemporalSeriesSupporter(DECIBEL
.asType(Dimensionless.class), null, new String[]
{"dB"}));
}
开发者ID:debrief,项目名称:limpet,代码行数:52,代码来源:CsvParser.java
示例19: testAsTypeValid
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
/**
* Test method for {@link javax.measure.Unit#asType(java.lang.Class)}.
*/
@Test
public void testAsTypeValid() {
one.asType(Dimensionless.class);
}
开发者ID:unitsofmeasurement,项目名称:uom-systems,代码行数:8,代码来源:UnitsTest.java
示例20: testAsTypeFails
import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
/**
* Test method for {@link javax.measure.Unit#asType(java.lang.Class)}.
*/
@Test(expected = ClassCastException.class)
public void testAsTypeFails() {
METER.asType(Dimensionless.class);
}
开发者ID:unitsofmeasurement,项目名称:uom-systems,代码行数:8,代码来源:UnitsTest.java
注:本文中的javax.measure.quantity.Dimensionless类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论