From d2d6fb3bccc011a1d997f4039ab3d417ecc03a76 Mon Sep 17 00:00:00 2001 From: luukkainen Date: Wed, 29 Oct 2008 09:49:33 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/3d/branches/dev@7345 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../stubs/BranchControlPoint.java | 321 --------------- .../stubs/BranchEndControlPoint.java | 277 ------------- .../stubs/BranchSplitComponent.java | 358 ----------------- .../processeditor/stubs/CodedComponent.java | 298 -------------- .../stubs/ConcentricReducer.java | 370 ----------------- .../stubs/DirectedControlPoint.java | 273 ------------- .../stubs/DualConnectedComponent.java | 298 -------------- .../stubs/DualInlineControlPoint.java | 321 --------------- .../stubs/DualSubControlPoint.java | 321 --------------- .../processeditor/stubs/EccentricReducer.java | 374 ------------------ .../simantics/processeditor/stubs/Elbow.java | 362 ----------------- .../processeditor/stubs/EndComponent.java | 298 -------------- .../stubs/EndComponentControlPoint.java | 301 -------------- .../processeditor/stubs/Equipment.java | 310 --------------- .../stubs/FixedAngleTurnComponent.java | 350 ---------------- .../stubs/FixedAngleTurnControlPoint.java | 369 ----------------- .../stubs/FixedLengthControlPoint.java | 317 --------------- .../stubs/FixedLengthInlineComponent.java | 350 ---------------- .../processeditor/stubs/HorizontalVessel.java | 342 ---------------- .../stubs/IBranchControlPoint.java | 16 - .../stubs/IBranchEndControlPoint.java | 16 - .../stubs/IBranchSplitComponent.java | 16 - .../processeditor/stubs/ICodedComponent.java | 16 - .../stubs/IConcentricReducer.java | 16 - .../stubs/IDirectedControlPoint.java | 16 - .../stubs/IDualConnectedComponent.java | 16 - .../stubs/IDualInlineControlPoint.java | 16 - .../stubs/IDualSubControlPoint.java | 16 - .../stubs/IEccentricReducer.java | 16 - .../simantics/processeditor/stubs/IElbow.java | 16 - .../processeditor/stubs/IEndComponent.java | 16 - .../stubs/IEndComponentControlPoint.java | 16 - .../processeditor/stubs/IEquipment.java | 16 - .../stubs/IFixedAngleTurnComponent.java | 16 - .../stubs/IFixedAngleTurnControlPoint.java | 16 - .../stubs/IFixedLengthControlPoint.java | 16 - .../stubs/IFixedLengthInlineComponent.java | 16 - .../stubs/IHorizontalVessel.java | 16 - .../processeditor/stubs/IInlineComponent.java | 16 - .../stubs/IInlineControlPoint.java | 16 - .../stubs/ILibraryComponent.java | 16 - .../stubs/IMultiConnectedComponent.java | 16 - .../stubs/INPortControlPoint.java | 16 - .../stubs/INonVisibleComponent.java | 16 - .../processeditor/stubs/INozzle.java | 16 - .../stubs/INozzleControlPoint.java | 16 - .../processeditor/stubs/IOffsetComponent.java | 16 - .../processeditor/stubs/IOffsettingPoint.java | 16 - .../processeditor/stubs/IP3DNode.java | 16 - .../processeditor/stubs/IPBSNode.java | 16 - .../stubs/IPathLegEndControlPoint.java | 16 - .../stubs/IPipeControlPoint.java | 16 - .../processeditor/stubs/IPipeRun.java | 16 - .../stubs/IPipelineComponent.java | 16 - .../simantics/processeditor/stubs/IPlant.java | 16 - .../stubs/IPlant3DProjectType.java | 16 - .../processeditor/stubs/IReducer.java | 16 - .../stubs/IRunEndControlPoint.java | 16 - .../stubs/ISingleConnectedComponent.java | 16 - .../stubs/ISizeChangeComponent.java | 16 - .../stubs/ISizeChangeControlPoint.java | 16 - .../processeditor/stubs/IStraight.java | 16 - .../processeditor/stubs/ITurnComponent.java | 16 - .../stubs/ITurnControlPoint.java | 16 - .../stubs/IUndirectedControlPoint.java | 16 - .../stubs/IVariableAngleTurnComponent.java | 16 - .../stubs/IVariableAngleTurnControlPoint.java | 16 - .../stubs/IVariableLengthControlPoint.java | 16 - .../stubs/IVariableLengthInlineComponent.java | 16 - .../processeditor/stubs/IVerticalVessel.java | 16 - .../processeditor/stubs/IVessel.java | 16 - .../processeditor/stubs/InlineComponent.java | 322 --------------- .../stubs/InlineControlPoint.java | 289 -------------- .../processeditor/stubs/LibraryComponent.java | 247 ------------ .../stubs/MultiConnectedComponent.java | 298 -------------- .../stubs/NPortControlPoint.java | 277 ------------- .../stubs/NonVisibleComponent.java | 298 -------------- .../simantics/processeditor/stubs/Nozzle.java | 318 --------------- .../stubs/NozzleControlPoint.java | 277 ------------- .../processeditor/stubs/OffsetComponent.java | 354 ----------------- .../processeditor/stubs/OffsettingPoint.java | 349 ---------------- .../processeditor/stubs/P3DNode.java | 189 --------- .../processeditor/stubs/PBSNode.java | 90 ----- .../stubs/PathLegEndControlPoint.java | 265 ------------- .../processeditor/stubs/PipeControlPoint.java | 261 ------------ .../processeditor/stubs/PipeRun.java | 253 ------------ .../stubs/PipelineComponent.java | 294 -------------- .../simantics/processeditor/stubs/Plant.java | 228 ----------- .../stubs/Plant3DProjectType.java | 63 --- .../processeditor/stubs/Plant3DResource.java | 272 ------------- .../processeditor/stubs/Reducer.java | 366 ----------------- .../stubs/RunEndControlPoint.java | 269 ------------- .../stubs/SingleConnectedComponent.java | 298 -------------- .../stubs/SizeChangeComponent.java | 354 ----------------- .../stubs/SizeChangeControlPoint.java | 325 --------------- .../processeditor/stubs/Straight.java | 338 ---------------- .../processeditor/stubs/TurnComponent.java | 322 --------------- .../processeditor/stubs/TurnControlPoint.java | 317 --------------- .../stubs/UndirectedControlPoint.java | 273 ------------- .../stubs/VariableAngleTurnComponent.java | 350 ---------------- .../stubs/VariableAngleTurnControlPoint.java | 362 ----------------- .../stubs/VariableLengthControlPoint.java | 293 -------------- .../stubs/VariableLengthInlineComponent.java | 326 --------------- .../processeditor/stubs/VerticalVessel.java | 342 ---------------- .../simantics/processeditor/stubs/Vessel.java | 314 --------------- 105 files changed, 16835 deletions(-) delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchEndControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchSplitComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/CodedComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ConcentricReducer.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DirectedControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualConnectedComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualInlineControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualSubControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EccentricReducer.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Elbow.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EndComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EndComponentControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Equipment.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedAngleTurnComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedAngleTurnControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedLengthControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedLengthInlineComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/HorizontalVessel.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchEndControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchSplitComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ICodedComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IConcentricReducer.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDirectedControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualConnectedComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualInlineControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualSubControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEccentricReducer.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IElbow.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEndComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEndComponentControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEquipment.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedAngleTurnComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedAngleTurnControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedLengthControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedLengthInlineComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IHorizontalVessel.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IInlineComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IInlineControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ILibraryComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IMultiConnectedComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INPortControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INonVisibleComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INozzle.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INozzleControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IOffsetComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IOffsettingPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IP3DNode.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPBSNode.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPathLegEndControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipeControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipeRun.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipelineComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPlant.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPlant3DProjectType.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IReducer.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IRunEndControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISingleConnectedComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISizeChangeComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISizeChangeControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IStraight.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ITurnComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ITurnControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IUndirectedControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableAngleTurnComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableAngleTurnControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableLengthControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableLengthInlineComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVerticalVessel.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVessel.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/InlineComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/InlineControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/LibraryComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/MultiConnectedComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NPortControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NonVisibleComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Nozzle.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NozzleControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/OffsetComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/OffsettingPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/P3DNode.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PBSNode.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PathLegEndControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipeControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipeRun.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipelineComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant3DProjectType.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant3DResource.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Reducer.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/RunEndControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SingleConnectedComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SizeChangeComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SizeChangeControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Straight.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/TurnComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/TurnControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/UndirectedControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableAngleTurnComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableAngleTurnControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableLengthControlPoint.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableLengthInlineComponent.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VerticalVessel.java delete mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Vessel.java diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchControlPoint.java deleted file mode 100644 index 23b0b359..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchControlPoint.java +++ /dev/null @@ -1,321 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class BranchControlPoint extends Entity implements IBranchControlPoint { - - public BranchControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public BranchControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static BranchControlPoint createDefault(Graph graph) { - return new BranchControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).BranchControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).BranchControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.FixedLengthControlPoint toFixedLengthControlPoint() { - return new org.simantics.processeditor.stubs.FixedLengthControlPoint(graph, resource); - } - - public BranchControlPoint toBranchControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.InlineControlPoint toInlineControlPoint() { - return new org.simantics.processeditor.stubs.InlineControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchEndControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchEndControlPoint.java deleted file mode 100644 index 47ded7e2..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchEndControlPoint.java +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class BranchEndControlPoint extends Entity implements IBranchEndControlPoint { - - public BranchEndControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public BranchEndControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static BranchEndControlPoint createDefault(Graph graph) { - return new BranchEndControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).BranchEndControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).BranchEndControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.PathLegEndControlPoint toPathLegEndControlPoint() { - return new org.simantics.processeditor.stubs.PathLegEndControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.RunEndControlPoint toRunEndControlPoint() { - return new org.simantics.processeditor.stubs.RunEndControlPoint(graph, resource); - } - - public BranchEndControlPoint toBranchEndControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.UndirectedControlPoint toUndirectedControlPoint() { - return new org.simantics.processeditor.stubs.UndirectedControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchSplitComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchSplitComponent.java deleted file mode 100644 index a5cfaa86..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/BranchSplitComponent.java +++ /dev/null @@ -1,358 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class BranchSplitComponent extends Entity implements IBranchSplitComponent { - - public BranchSplitComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public BranchSplitComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static BranchSplitComponent createDefault(Graph graph) { - return new BranchSplitComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).BranchSplitComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).BranchSplitComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.NonVisibleComponent toNonVisibleComponent() { - return new org.simantics.processeditor.stubs.NonVisibleComponent(graph, resource); - } - - public BranchSplitComponent toBranchSplitComponent() { - return this; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.InlineComponent toInlineComponent() { - return new org.simantics.processeditor.stubs.InlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.FixedLengthInlineComponent toFixedLengthInlineComponent() { - return new org.simantics.processeditor.stubs.FixedLengthInlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/CodedComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/CodedComponent.java deleted file mode 100644 index 4b250d9b..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/CodedComponent.java +++ /dev/null @@ -1,298 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class CodedComponent extends Entity implements ICodedComponent { - - public CodedComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public CodedComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static CodedComponent createDefault(Graph graph) { - return new CodedComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).CodedComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).CodedComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public CodedComponent toCodedComponent() { - return this; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ConcentricReducer.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ConcentricReducer.java deleted file mode 100644 index 1af6540f..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ConcentricReducer.java +++ /dev/null @@ -1,370 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class ConcentricReducer extends Entity implements IConcentricReducer { - - public ConcentricReducer(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public ConcentricReducer(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static ConcentricReducer createDefault(Graph graph) { - return new ConcentricReducer(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ConcentricReducer)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ConcentricReducer; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.CodedComponent toCodedComponent() { - return new org.simantics.processeditor.stubs.CodedComponent(graph, resource); - } - - public ConcentricReducer toConcentricReducer() { - return this; - } - - public org.simantics.processeditor.stubs.Reducer toReducer() { - return new org.simantics.processeditor.stubs.Reducer(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.SizeChangeComponent toSizeChangeComponent() { - return new org.simantics.processeditor.stubs.SizeChangeComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.InlineComponent toInlineComponent() { - return new org.simantics.processeditor.stubs.InlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.DualConnectedComponent toDualConnectedComponent() { - return new org.simantics.processeditor.stubs.DualConnectedComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.FixedLengthInlineComponent toFixedLengthInlineComponent() { - return new org.simantics.processeditor.stubs.FixedLengthInlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DirectedControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DirectedControlPoint.java deleted file mode 100644 index e87f67ef..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DirectedControlPoint.java +++ /dev/null @@ -1,273 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class DirectedControlPoint extends Entity implements IDirectedControlPoint { - - public DirectedControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public DirectedControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static DirectedControlPoint createDefault(Graph graph) { - return new DirectedControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).DirectedControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).DirectedControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.PathLegEndControlPoint toPathLegEndControlPoint() { - return new org.simantics.processeditor.stubs.PathLegEndControlPoint(graph, resource); - } - - public DirectedControlPoint toDirectedControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.RunEndControlPoint toRunEndControlPoint() { - return new org.simantics.processeditor.stubs.RunEndControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualConnectedComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualConnectedComponent.java deleted file mode 100644 index bc07e75f..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualConnectedComponent.java +++ /dev/null @@ -1,298 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class DualConnectedComponent extends Entity implements IDualConnectedComponent { - - public DualConnectedComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public DualConnectedComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static DualConnectedComponent createDefault(Graph graph) { - return new DualConnectedComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).DualConnectedComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).DualConnectedComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public DualConnectedComponent toDualConnectedComponent() { - return this; - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualInlineControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualInlineControlPoint.java deleted file mode 100644 index 76948878..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualInlineControlPoint.java +++ /dev/null @@ -1,321 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class DualInlineControlPoint extends Entity implements IDualInlineControlPoint { - - public DualInlineControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public DualInlineControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static DualInlineControlPoint createDefault(Graph graph) { - return new DualInlineControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).DualInlineControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).DualInlineControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.FixedLengthControlPoint toFixedLengthControlPoint() { - return new org.simantics.processeditor.stubs.FixedLengthControlPoint(graph, resource); - } - - public DualInlineControlPoint toDualInlineControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.InlineControlPoint toInlineControlPoint() { - return new org.simantics.processeditor.stubs.InlineControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualSubControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualSubControlPoint.java deleted file mode 100644 index 14c4b997..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/DualSubControlPoint.java +++ /dev/null @@ -1,321 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class DualSubControlPoint extends Entity implements IDualSubControlPoint { - - public DualSubControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public DualSubControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static DualSubControlPoint createDefault(Graph graph) { - return new DualSubControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).DualSubControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).DualSubControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.FixedLengthControlPoint toFixedLengthControlPoint() { - return new org.simantics.processeditor.stubs.FixedLengthControlPoint(graph, resource); - } - - public DualSubControlPoint toDualSubControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.InlineControlPoint toInlineControlPoint() { - return new org.simantics.processeditor.stubs.InlineControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EccentricReducer.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EccentricReducer.java deleted file mode 100644 index 7136e6a4..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EccentricReducer.java +++ /dev/null @@ -1,374 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class EccentricReducer extends Entity implements IEccentricReducer { - - public EccentricReducer(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public EccentricReducer(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static EccentricReducer createDefault(Graph graph) { - return new EccentricReducer(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).EccentricReducer)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).EccentricReducer; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.CodedComponent toCodedComponent() { - return new org.simantics.processeditor.stubs.CodedComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.OffsetComponent toOffsetComponent() { - return new org.simantics.processeditor.stubs.OffsetComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.Reducer toReducer() { - return new org.simantics.processeditor.stubs.Reducer(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.SizeChangeComponent toSizeChangeComponent() { - return new org.simantics.processeditor.stubs.SizeChangeComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.InlineComponent toInlineComponent() { - return new org.simantics.processeditor.stubs.InlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.DualConnectedComponent toDualConnectedComponent() { - return new org.simantics.processeditor.stubs.DualConnectedComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.FixedLengthInlineComponent toFixedLengthInlineComponent() { - return new org.simantics.processeditor.stubs.FixedLengthInlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public EccentricReducer toEccentricReducer() { - return this; - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Elbow.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Elbow.java deleted file mode 100644 index 7bfdcbe5..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Elbow.java +++ /dev/null @@ -1,362 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class Elbow extends Entity implements IElbow { - - public Elbow(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public Elbow(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static Elbow createDefault(Graph graph) { - return new Elbow(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Elbow)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Elbow; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.CodedComponent toCodedComponent() { - return new org.simantics.processeditor.stubs.CodedComponent(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.VariableAngleTurnComponent toVariableAngleTurnComponent() { - return new org.simantics.processeditor.stubs.VariableAngleTurnComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.DualConnectedComponent toDualConnectedComponent() { - return new org.simantics.processeditor.stubs.DualConnectedComponent(graph, resource); - } - - public Elbow toElbow() { - return this; - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.TurnComponent toTurnComponent() { - return new org.simantics.processeditor.stubs.TurnComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getTurnRadius() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnRadius); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setTurnRadius(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnRadius; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getTurnAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setTurnAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EndComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EndComponent.java deleted file mode 100644 index cb52f1a9..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EndComponent.java +++ /dev/null @@ -1,298 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class EndComponent extends Entity implements IEndComponent { - - public EndComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public EndComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static EndComponent createDefault(Graph graph) { - return new EndComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).EndComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).EndComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public EndComponent toEndComponent() { - return this; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EndComponentControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EndComponentControlPoint.java deleted file mode 100644 index 9d178cbd..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/EndComponentControlPoint.java +++ /dev/null @@ -1,301 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class EndComponentControlPoint extends Entity implements IEndComponentControlPoint { - - public EndComponentControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public EndComponentControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static EndComponentControlPoint createDefault(Graph graph) { - return new EndComponentControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).EndComponentControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).EndComponentControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.PathLegEndControlPoint toPathLegEndControlPoint() { - return new org.simantics.processeditor.stubs.PathLegEndControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.RunEndControlPoint toRunEndControlPoint() { - return new org.simantics.processeditor.stubs.RunEndControlPoint(graph, resource); - } - - public EndComponentControlPoint toEndComponentControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.UndirectedControlPoint toUndirectedControlPoint() { - return new org.simantics.processeditor.stubs.UndirectedControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Equipment.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Equipment.java deleted file mode 100644 index 038c1ac4..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Equipment.java +++ /dev/null @@ -1,310 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class Equipment extends Entity implements IEquipment { - - public Equipment(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public Equipment(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static Equipment createDefault(Graph graph) { - return new Equipment(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Equipment)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Equipment; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public Equipment toEquipment() { - return this; - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.Nozzle getNozzle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.Nozzle(graph, statements[0].getObject()); - } - - public void addNozzle(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle, v.getResource()); - } - - public void setNozzle(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle]&[Property] - public Collection getNozzleDefinition() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleDefinition); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new Entity(graph, s.getObject())); - return ret; - } - - // [Nozzle]&[Property] - public void addNozzleDefinition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleDefinition, v.getResource()); - } - - public String[] getNozzleRestriction() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleRestriction); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return (String[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setNozzleRestriction(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleRestriction; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).IntegerRangeUnion; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedAngleTurnComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedAngleTurnComponent.java deleted file mode 100644 index d7405cf7..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedAngleTurnComponent.java +++ /dev/null @@ -1,350 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class FixedAngleTurnComponent extends Entity implements IFixedAngleTurnComponent { - - public FixedAngleTurnComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public FixedAngleTurnComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static FixedAngleTurnComponent createDefault(Graph graph) { - return new FixedAngleTurnComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).FixedAngleTurnComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).FixedAngleTurnComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public FixedAngleTurnComponent toFixedAngleTurnComponent() { - return this; - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.TurnComponent toTurnComponent() { - return new org.simantics.processeditor.stubs.TurnComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getTurnAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setTurnAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedAngleTurnControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedAngleTurnControlPoint.java deleted file mode 100644 index ff2c1dfc..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedAngleTurnControlPoint.java +++ /dev/null @@ -1,369 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class FixedAngleTurnControlPoint extends Entity implements IFixedAngleTurnControlPoint { - - public FixedAngleTurnControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public FixedAngleTurnControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static FixedAngleTurnControlPoint createDefault(Graph graph) { - return new FixedAngleTurnControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).FixedAngleTurnControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).FixedAngleTurnControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.PathLegEndControlPoint toPathLegEndControlPoint() { - return new org.simantics.processeditor.stubs.PathLegEndControlPoint(graph, resource); - } - - public FixedAngleTurnControlPoint toFixedAngleTurnControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.TurnControlPoint toTurnControlPoint() { - return new org.simantics.processeditor.stubs.TurnControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getTurnAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setTurnAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public boolean[] getIsReversed() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).IsReversed); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (boolean[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setIsReversed(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).IsReversed; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Boolean; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedLengthControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedLengthControlPoint.java deleted file mode 100644 index de42b99c..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedLengthControlPoint.java +++ /dev/null @@ -1,317 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class FixedLengthControlPoint extends Entity implements IFixedLengthControlPoint { - - public FixedLengthControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public FixedLengthControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static FixedLengthControlPoint createDefault(Graph graph) { - return new FixedLengthControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).FixedLengthControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).FixedLengthControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public FixedLengthControlPoint toFixedLengthControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.InlineControlPoint toInlineControlPoint() { - return new org.simantics.processeditor.stubs.InlineControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedLengthInlineComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedLengthInlineComponent.java deleted file mode 100644 index d4300469..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/FixedLengthInlineComponent.java +++ /dev/null @@ -1,350 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class FixedLengthInlineComponent extends Entity implements IFixedLengthInlineComponent { - - public FixedLengthInlineComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public FixedLengthInlineComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static FixedLengthInlineComponent createDefault(Graph graph) { - return new FixedLengthInlineComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).FixedLengthInlineComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).FixedLengthInlineComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.InlineComponent toInlineComponent() { - return new org.simantics.processeditor.stubs.InlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public FixedLengthInlineComponent toFixedLengthInlineComponent() { - return this; - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/HorizontalVessel.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/HorizontalVessel.java deleted file mode 100644 index 623f640c..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/HorizontalVessel.java +++ /dev/null @@ -1,342 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class HorizontalVessel extends Entity implements IHorizontalVessel { - - public HorizontalVessel(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public HorizontalVessel(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static HorizontalVessel createDefault(Graph graph) { - return new HorizontalVessel(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HorizontalVessel)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HorizontalVessel; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public HorizontalVessel toHorizontalVessel() { - return this; - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.Vessel toVessel() { - return new org.simantics.processeditor.stubs.Vessel(graph, resource); - } - - public org.simantics.processeditor.stubs.Equipment toEquipment() { - return new org.simantics.processeditor.stubs.Equipment(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.Nozzle getNozzle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.Nozzle(graph, statements[0].getObject()); - } - - public void addNozzle(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle, v.getResource()); - } - - public void setNozzle(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle]&[Property] - public Collection getNozzleDefinition() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleDefinition); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new Entity(graph, s.getObject())); - return ret; - } - - // [Nozzle]&[Property] - public void addNozzleDefinition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleDefinition, v.getResource()); - } - - public String[] getNozzleRestriction() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleRestriction); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return (String[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setNozzleRestriction(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleRestriction; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).IntegerRangeUnion; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchControlPoint.java deleted file mode 100644 index 26648c00..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IBranchControlPoint extends org.simantics.processeditor.stubs.IFixedLengthControlPoint { - BranchControlPoint toBranchControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchEndControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchEndControlPoint.java deleted file mode 100644 index 24aeed88..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchEndControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IBranchEndControlPoint extends org.simantics.processeditor.stubs.IUndirectedControlPoint { - BranchEndControlPoint toBranchEndControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchSplitComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchSplitComponent.java deleted file mode 100644 index 33251629..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IBranchSplitComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IBranchSplitComponent extends org.simantics.processeditor.stubs.INonVisibleComponent, org.simantics.processeditor.stubs.IFixedLengthInlineComponent { - BranchSplitComponent toBranchSplitComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ICodedComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ICodedComponent.java deleted file mode 100644 index 410b4358..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ICodedComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface ICodedComponent extends org.simantics.processeditor.stubs.IPipelineComponent { - CodedComponent toCodedComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IConcentricReducer.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IConcentricReducer.java deleted file mode 100644 index 259da001..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IConcentricReducer.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IConcentricReducer extends org.simantics.processeditor.stubs.IReducer { - ConcentricReducer toConcentricReducer(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDirectedControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDirectedControlPoint.java deleted file mode 100644 index 526d9377..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDirectedControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IDirectedControlPoint extends org.simantics.processeditor.stubs.IRunEndControlPoint { - DirectedControlPoint toDirectedControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualConnectedComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualConnectedComponent.java deleted file mode 100644 index c9a8a94d..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualConnectedComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IDualConnectedComponent extends org.simantics.processeditor.stubs.IPipelineComponent { - DualConnectedComponent toDualConnectedComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualInlineControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualInlineControlPoint.java deleted file mode 100644 index 005fc3dc..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualInlineControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IDualInlineControlPoint extends org.simantics.processeditor.stubs.IFixedLengthControlPoint { - DualInlineControlPoint toDualInlineControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualSubControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualSubControlPoint.java deleted file mode 100644 index ba8c8423..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IDualSubControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IDualSubControlPoint extends org.simantics.processeditor.stubs.IFixedLengthControlPoint { - DualSubControlPoint toDualSubControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEccentricReducer.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEccentricReducer.java deleted file mode 100644 index 68b77e12..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEccentricReducer.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IEccentricReducer extends org.simantics.processeditor.stubs.IOffsetComponent, org.simantics.processeditor.stubs.IReducer { - EccentricReducer toEccentricReducer(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IElbow.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IElbow.java deleted file mode 100644 index 6476b565..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IElbow.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IElbow extends org.simantics.processeditor.stubs.IDualConnectedComponent, org.simantics.processeditor.stubs.IVariableAngleTurnComponent, org.simantics.processeditor.stubs.ICodedComponent { - Elbow toElbow(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEndComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEndComponent.java deleted file mode 100644 index 1b81a6b1..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEndComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IEndComponent extends org.simantics.processeditor.stubs.IPipelineComponent { - EndComponent toEndComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEndComponentControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEndComponentControlPoint.java deleted file mode 100644 index 0636b813..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEndComponentControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IEndComponentControlPoint extends org.simantics.processeditor.stubs.IUndirectedControlPoint { - EndComponentControlPoint toEndComponentControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEquipment.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEquipment.java deleted file mode 100644 index 027f5b35..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IEquipment.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IEquipment extends org.simantics.processeditor.stubs.ILibraryComponent { - Equipment toEquipment(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedAngleTurnComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedAngleTurnComponent.java deleted file mode 100644 index 08b62656..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedAngleTurnComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IFixedAngleTurnComponent extends org.simantics.processeditor.stubs.ITurnComponent { - FixedAngleTurnComponent toFixedAngleTurnComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedAngleTurnControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedAngleTurnControlPoint.java deleted file mode 100644 index f1eaca7a..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedAngleTurnControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IFixedAngleTurnControlPoint extends org.simantics.processeditor.stubs.ITurnControlPoint { - FixedAngleTurnControlPoint toFixedAngleTurnControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedLengthControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedLengthControlPoint.java deleted file mode 100644 index 7055242c..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedLengthControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IFixedLengthControlPoint extends org.simantics.processeditor.stubs.IInlineControlPoint { - FixedLengthControlPoint toFixedLengthControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedLengthInlineComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedLengthInlineComponent.java deleted file mode 100644 index 7aee813a..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IFixedLengthInlineComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IFixedLengthInlineComponent extends org.simantics.processeditor.stubs.IInlineComponent { - FixedLengthInlineComponent toFixedLengthInlineComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IHorizontalVessel.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IHorizontalVessel.java deleted file mode 100644 index 640d0347..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IHorizontalVessel.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IHorizontalVessel extends org.simantics.processeditor.stubs.IVessel { - HorizontalVessel toHorizontalVessel(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IInlineComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IInlineComponent.java deleted file mode 100644 index 9b5fa594..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IInlineComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IInlineComponent extends org.simantics.processeditor.stubs.IPipelineComponent { - InlineComponent toInlineComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IInlineControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IInlineControlPoint.java deleted file mode 100644 index a8359bcb..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IInlineControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IInlineControlPoint extends org.simantics.processeditor.stubs.IPipeControlPoint { - InlineControlPoint toInlineControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ILibraryComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ILibraryComponent.java deleted file mode 100644 index bad804ce..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ILibraryComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface ILibraryComponent extends org.simantics.processeditor.stubs.IPBSNode, org.simantics.processeditor.stubs.IP3DNode { - LibraryComponent toLibraryComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IMultiConnectedComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IMultiConnectedComponent.java deleted file mode 100644 index aa837310..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IMultiConnectedComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IMultiConnectedComponent extends org.simantics.processeditor.stubs.IPipelineComponent { - MultiConnectedComponent toMultiConnectedComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INPortControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INPortControlPoint.java deleted file mode 100644 index 99d3a8f3..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INPortControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface INPortControlPoint extends org.simantics.processeditor.stubs.IDirectedControlPoint { - NPortControlPoint toNPortControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INonVisibleComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INonVisibleComponent.java deleted file mode 100644 index d3ec07ed..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INonVisibleComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface INonVisibleComponent extends org.simantics.processeditor.stubs.IPipelineComponent { - NonVisibleComponent toNonVisibleComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INozzle.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INozzle.java deleted file mode 100644 index 6daaa915..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INozzle.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface INozzle extends org.simantics.processeditor.stubs.ILibraryComponent { - Nozzle toNozzle(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INozzleControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INozzleControlPoint.java deleted file mode 100644 index e8414618..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/INozzleControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface INozzleControlPoint extends org.simantics.processeditor.stubs.IDirectedControlPoint { - NozzleControlPoint toNozzleControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IOffsetComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IOffsetComponent.java deleted file mode 100644 index dfba171a..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IOffsetComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IOffsetComponent extends org.simantics.processeditor.stubs.IFixedLengthInlineComponent { - OffsetComponent toOffsetComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IOffsettingPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IOffsettingPoint.java deleted file mode 100644 index d6b16b0a..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IOffsettingPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IOffsettingPoint extends org.simantics.processeditor.stubs.IDualInlineControlPoint { - OffsettingPoint toOffsettingPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IP3DNode.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IP3DNode.java deleted file mode 100644 index 3cf037eb..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IP3DNode.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IP3DNode extends org.simantics.proconf.g3d.stubs.IG3DNode { - P3DNode toP3DNode(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPBSNode.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPBSNode.java deleted file mode 100644 index fdfdda62..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPBSNode.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IPBSNode { - PBSNode toPBSNode(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPathLegEndControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPathLegEndControlPoint.java deleted file mode 100644 index bdfe5434..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPathLegEndControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IPathLegEndControlPoint extends org.simantics.processeditor.stubs.IPipeControlPoint { - PathLegEndControlPoint toPathLegEndControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipeControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipeControlPoint.java deleted file mode 100644 index e332c071..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipeControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IPipeControlPoint { - PipeControlPoint toPipeControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipeRun.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipeRun.java deleted file mode 100644 index a297bd7e..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipeRun.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IPipeRun extends org.simantics.processeditor.stubs.IP3DNode { - PipeRun toPipeRun(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipelineComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipelineComponent.java deleted file mode 100644 index d1d7dffb..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPipelineComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IPipelineComponent extends org.simantics.processeditor.stubs.ILibraryComponent { - PipelineComponent toPipelineComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPlant.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPlant.java deleted file mode 100644 index b054d010..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPlant.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IPlant extends org.simantics.processeditor.stubs.IPBSNode, org.simantics.processeditor.stubs.IP3DNode { - Plant toPlant(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPlant3DProjectType.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPlant3DProjectType.java deleted file mode 100644 index b2d54160..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IPlant3DProjectType.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IPlant3DProjectType extends org.simantics.layer0.stubs.IProjectType { - Plant3DProjectType toPlant3DProjectType(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IReducer.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IReducer.java deleted file mode 100644 index 89609431..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IReducer.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IReducer extends org.simantics.processeditor.stubs.IDualConnectedComponent, org.simantics.processeditor.stubs.IFixedLengthInlineComponent, org.simantics.processeditor.stubs.ISizeChangeComponent, org.simantics.processeditor.stubs.ICodedComponent { - Reducer toReducer(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IRunEndControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IRunEndControlPoint.java deleted file mode 100644 index 66f7d2c4..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IRunEndControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IRunEndControlPoint extends org.simantics.processeditor.stubs.IPathLegEndControlPoint { - RunEndControlPoint toRunEndControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISingleConnectedComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISingleConnectedComponent.java deleted file mode 100644 index 9caed2be..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISingleConnectedComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface ISingleConnectedComponent extends org.simantics.processeditor.stubs.IPipelineComponent { - SingleConnectedComponent toSingleConnectedComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISizeChangeComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISizeChangeComponent.java deleted file mode 100644 index f6f6b530..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISizeChangeComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface ISizeChangeComponent extends org.simantics.processeditor.stubs.IFixedLengthInlineComponent { - SizeChangeComponent toSizeChangeComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISizeChangeControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISizeChangeControlPoint.java deleted file mode 100644 index d66f2bbc..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ISizeChangeControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface ISizeChangeControlPoint extends org.simantics.processeditor.stubs.IDualInlineControlPoint { - SizeChangeControlPoint toSizeChangeControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IStraight.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IStraight.java deleted file mode 100644 index a3aaf2ae..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IStraight.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IStraight extends org.simantics.processeditor.stubs.IVariableLengthInlineComponent, org.simantics.processeditor.stubs.IDualConnectedComponent, org.simantics.processeditor.stubs.ICodedComponent { - Straight toStraight(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ITurnComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ITurnComponent.java deleted file mode 100644 index 2f55b820..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ITurnComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface ITurnComponent extends org.simantics.processeditor.stubs.IPipelineComponent { - TurnComponent toTurnComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ITurnControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ITurnControlPoint.java deleted file mode 100644 index c5f01145..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/ITurnControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface ITurnControlPoint extends org.simantics.processeditor.stubs.IPathLegEndControlPoint { - TurnControlPoint toTurnControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IUndirectedControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IUndirectedControlPoint.java deleted file mode 100644 index ae643a82..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IUndirectedControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IUndirectedControlPoint extends org.simantics.processeditor.stubs.IRunEndControlPoint { - UndirectedControlPoint toUndirectedControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableAngleTurnComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableAngleTurnComponent.java deleted file mode 100644 index bda5f649..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableAngleTurnComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IVariableAngleTurnComponent extends org.simantics.processeditor.stubs.ITurnComponent { - VariableAngleTurnComponent toVariableAngleTurnComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableAngleTurnControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableAngleTurnControlPoint.java deleted file mode 100644 index 0c7dbb31..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableAngleTurnControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IVariableAngleTurnControlPoint extends org.simantics.processeditor.stubs.ITurnControlPoint { - VariableAngleTurnControlPoint toVariableAngleTurnControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableLengthControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableLengthControlPoint.java deleted file mode 100644 index dae5dc19..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableLengthControlPoint.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IVariableLengthControlPoint extends org.simantics.processeditor.stubs.IInlineControlPoint { - VariableLengthControlPoint toVariableLengthControlPoint(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableLengthInlineComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableLengthInlineComponent.java deleted file mode 100644 index 1df3c42a..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVariableLengthInlineComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IVariableLengthInlineComponent extends org.simantics.processeditor.stubs.IInlineComponent { - VariableLengthInlineComponent toVariableLengthInlineComponent(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVerticalVessel.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVerticalVessel.java deleted file mode 100644 index 99dcbd4f..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVerticalVessel.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IVerticalVessel extends org.simantics.processeditor.stubs.IVessel { - VerticalVessel toVerticalVessel(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVessel.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVessel.java deleted file mode 100644 index ab8a1369..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/IVessel.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -public interface IVessel extends org.simantics.processeditor.stubs.IEquipment { - Vessel toVessel(); -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/InlineComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/InlineComponent.java deleted file mode 100644 index 3210d935..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/InlineComponent.java +++ /dev/null @@ -1,322 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class InlineComponent extends Entity implements IInlineComponent { - - public InlineComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public InlineComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static InlineComponent createDefault(Graph graph) { - return new InlineComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).InlineComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).InlineComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public InlineComponent toInlineComponent() { - return this; - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/InlineControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/InlineControlPoint.java deleted file mode 100644 index c4043228..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/InlineControlPoint.java +++ /dev/null @@ -1,289 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class InlineControlPoint extends Entity implements IInlineControlPoint { - - public InlineControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public InlineControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static InlineControlPoint createDefault(Graph graph) { - return new InlineControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).InlineControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).InlineControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public InlineControlPoint toInlineControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/LibraryComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/LibraryComponent.java deleted file mode 100644 index 615f21a8..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/LibraryComponent.java +++ /dev/null @@ -1,247 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class LibraryComponent extends Entity implements ILibraryComponent { - - public LibraryComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public LibraryComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static LibraryComponent createDefault(Graph graph) { - return new LibraryComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).LibraryComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).LibraryComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public LibraryComponent toLibraryComponent() { - return this; - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/MultiConnectedComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/MultiConnectedComponent.java deleted file mode 100644 index 57db6c1d..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/MultiConnectedComponent.java +++ /dev/null @@ -1,298 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class MultiConnectedComponent extends Entity implements IMultiConnectedComponent { - - public MultiConnectedComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public MultiConnectedComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static MultiConnectedComponent createDefault(Graph graph) { - return new MultiConnectedComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).MultiConnectedComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).MultiConnectedComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public MultiConnectedComponent toMultiConnectedComponent() { - return this; - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NPortControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NPortControlPoint.java deleted file mode 100644 index 1ae517af..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NPortControlPoint.java +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class NPortControlPoint extends Entity implements INPortControlPoint { - - public NPortControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public NPortControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static NPortControlPoint createDefault(Graph graph) { - return new NPortControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).NPortControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).NPortControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.PathLegEndControlPoint toPathLegEndControlPoint() { - return new org.simantics.processeditor.stubs.PathLegEndControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.DirectedControlPoint toDirectedControlPoint() { - return new org.simantics.processeditor.stubs.DirectedControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.RunEndControlPoint toRunEndControlPoint() { - return new org.simantics.processeditor.stubs.RunEndControlPoint(graph, resource); - } - - public NPortControlPoint toNPortControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NonVisibleComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NonVisibleComponent.java deleted file mode 100644 index 04beebe2..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NonVisibleComponent.java +++ /dev/null @@ -1,298 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class NonVisibleComponent extends Entity implements INonVisibleComponent { - - public NonVisibleComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public NonVisibleComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static NonVisibleComponent createDefault(Graph graph) { - return new NonVisibleComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).NonVisibleComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).NonVisibleComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public NonVisibleComponent toNonVisibleComponent() { - return this; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Nozzle.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Nozzle.java deleted file mode 100644 index b6641e69..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Nozzle.java +++ /dev/null @@ -1,318 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class Nozzle extends Entity implements INozzle { - - public Nozzle(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public Nozzle(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static Nozzle createDefault(Graph graph) { - return new Nozzle(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Nozzle)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Nozzle; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Nozzle toNozzle() { - return this; - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NozzleControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NozzleControlPoint.java deleted file mode 100644 index 43eaa7b1..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/NozzleControlPoint.java +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class NozzleControlPoint extends Entity implements INozzleControlPoint { - - public NozzleControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public NozzleControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static NozzleControlPoint createDefault(Graph graph) { - return new NozzleControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).NozzleControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).NozzleControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.PathLegEndControlPoint toPathLegEndControlPoint() { - return new org.simantics.processeditor.stubs.PathLegEndControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.DirectedControlPoint toDirectedControlPoint() { - return new org.simantics.processeditor.stubs.DirectedControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.RunEndControlPoint toRunEndControlPoint() { - return new org.simantics.processeditor.stubs.RunEndControlPoint(graph, resource); - } - - public NozzleControlPoint toNozzleControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/OffsetComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/OffsetComponent.java deleted file mode 100644 index ebe0208d..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/OffsetComponent.java +++ /dev/null @@ -1,354 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class OffsetComponent extends Entity implements IOffsetComponent { - - public OffsetComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public OffsetComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static OffsetComponent createDefault(Graph graph) { - return new OffsetComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).OffsetComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).OffsetComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public OffsetComponent toOffsetComponent() { - return this; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.InlineComponent toInlineComponent() { - return new org.simantics.processeditor.stubs.InlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.FixedLengthInlineComponent toFixedLengthInlineComponent() { - return new org.simantics.processeditor.stubs.FixedLengthInlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/OffsettingPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/OffsettingPoint.java deleted file mode 100644 index a82da720..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/OffsettingPoint.java +++ /dev/null @@ -1,349 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class OffsettingPoint extends Entity implements IOffsettingPoint { - - public OffsettingPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public OffsettingPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static OffsettingPoint createDefault(Graph graph) { - return new OffsettingPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).OffsettingPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).OffsettingPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.FixedLengthControlPoint toFixedLengthControlPoint() { - return new org.simantics.processeditor.stubs.FixedLengthControlPoint(graph, resource); - } - - public OffsettingPoint toOffsettingPoint() { - return this; - } - - public org.simantics.processeditor.stubs.DualInlineControlPoint toDualInlineControlPoint() { - return new org.simantics.processeditor.stubs.DualInlineControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.InlineControlPoint toInlineControlPoint() { - return new org.simantics.processeditor.stubs.InlineControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getOffset() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasOffset); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setOffset(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasOffset; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/P3DNode.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/P3DNode.java deleted file mode 100644 index 93a56a65..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/P3DNode.java +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class P3DNode extends Entity implements IP3DNode { - - public P3DNode(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public P3DNode(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static P3DNode createDefault(Graph graph) { - return new P3DNode(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).P3DNode)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).P3DNode; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public P3DNode toP3DNode() { - return this; - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PBSNode.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PBSNode.java deleted file mode 100644 index 0c76584c..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PBSNode.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class PBSNode extends Entity implements IPBSNode { - - public PBSNode(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public PBSNode(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static PBSNode createDefault(Graph graph) { - return new PBSNode(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).PBSNode)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).PBSNode; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public PBSNode toPBSNode() { - return this; - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PathLegEndControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PathLegEndControlPoint.java deleted file mode 100644 index 7c471d3b..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PathLegEndControlPoint.java +++ /dev/null @@ -1,265 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class PathLegEndControlPoint extends Entity implements IPathLegEndControlPoint { - - public PathLegEndControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public PathLegEndControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static PathLegEndControlPoint createDefault(Graph graph) { - return new PathLegEndControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).PathLegEndControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).PathLegEndControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public PathLegEndControlPoint toPathLegEndControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipeControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipeControlPoint.java deleted file mode 100644 index d239eeb3..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipeControlPoint.java +++ /dev/null @@ -1,261 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class PipeControlPoint extends Entity implements IPipeControlPoint { - - public PipeControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public PipeControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static PipeControlPoint createDefault(Graph graph) { - return new PipeControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).PipeControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).PipeControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public PipeControlPoint toPipeControlPoint() { - return this; - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipeRun.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipeRun.java deleted file mode 100644 index 34eb3795..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipeRun.java +++ /dev/null @@ -1,253 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class PipeRun extends Entity implements IPipeRun { - - public PipeRun(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public PipeRun(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static PipeRun createDefault(Graph graph) { - return new PipeRun(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).PipeRun)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).PipeRun; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public PipeRun toPipeRun() { - return this; - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getTurnRadius() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnRadius); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setTurnRadius(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnRadius; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getControlPoints() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoints); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addControlPoints(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoints, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipelineComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipelineComponent.java deleted file mode 100644 index d91772cf..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/PipelineComponent.java +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class PipelineComponent extends Entity implements IPipelineComponent { - - public PipelineComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public PipelineComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static PipelineComponent createDefault(Graph graph) { - return new PipelineComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).PipelineComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).PipelineComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public PipelineComponent toPipelineComponent() { - return this; - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant.java deleted file mode 100644 index d3ade888..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant.java +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class Plant extends Entity implements IPlant { - - public Plant(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public Plant(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static Plant createDefault(Graph graph) { - return new Plant(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Plant)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Plant; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public Plant toPlant() { - return this; - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant3DProjectType.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant3DProjectType.java deleted file mode 100644 index 8339a4c4..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant3DProjectType.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class Plant3DProjectType extends Entity implements IPlant3DProjectType { - - public Plant3DProjectType(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public Plant3DProjectType(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static Plant3DProjectType createDefault(Graph graph) { - return new Plant3DProjectType(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Plant3DProjectType)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Plant3DProjectType; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public Plant3DProjectType toPlant3DProjectType() { - return this; - } - - public org.simantics.layer0.stubs.ProjectType toProjectType() { - return new org.simantics.layer0.stubs.ProjectType(graph, resource); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant3DResource.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant3DResource.java deleted file mode 100644 index 0280a4ca..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Plant3DResource.java +++ /dev/null @@ -1,272 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - - -import org.simantics.db.Resource; -import org.simantics.db.Graph; -import org.simantics.db.Session; -import org.simantics.db.exceptions.Layer0MissingException; -import org.simantics.db.exceptions.ResourceNotFoundException; - -public class Plant3DResource { - - public final Resource BranchControlPoint; - public final Resource BranchEndControlPoint; - public final Resource BranchSplitComponent; - public final Resource CodedComponent; - public final Resource ConcentricReducer; - public final Resource ControlPointOf; - public final Resource ControlPointOfPipeRun; - public final Resource DirectedControlPoint; - public final Resource DualConnectedComponent; - public final Resource DualInlineControlPoint; - public final Resource DualSubControlPoint; - public final Resource EccentricReducer; - public final Resource Elbow; - public final Resource EndComponent; - public final Resource EndComponentControlPoint; - public final Resource Equipment; - public final Resource FixedAngleTurnComponent; - public final Resource FixedAngleTurnControlPoint; - public final Resource FixedLengthControlPoint; - public final Resource FixedLengthInlineComponent; - public final Resource HasChildStructure; - public final Resource HasControlPoint; - public final Resource HasControlPoints; - public final Resource HasGraphics; - public final Resource HasHeight; - public final Resource HasLength; - public final Resource HasNext; - public final Resource HasNozzle; - public final Resource HasNozzleDefinition; - public final Resource HasNozzleRestriction; - public final Resource HasOffset; - public final Resource HasParentStructure; - public final Resource HasPipeDiameter; - public final Resource HasPrevious; - public final Resource HasRotationAngle; - public final Resource HasSubPoint; - public final Resource HasTurnAngle; - public final Resource HasTurnAxis; - public final Resource HasTurnRadius; - public final Resource HorizontalVessel; - public final Resource InlineComponent; - public final Resource InlineControlPoint; - public final Resource IsReversed; - public final Resource LibraryComponent; - public final Resource MultiConnectedComponent; - public final Resource NPortControlPoint; - public final Resource NonVisibleComponent; - public final Resource Nozzle; - public final Resource NozzleControlPoint; - public final Resource NozzleOf; - public final Resource OffsetComponent; - public final Resource OffsettingPoint; - public final Resource P3DNode; - public final Resource PBSNode; - public final Resource PathLegEndControlPoint; - public final Resource PipeControlPoint; - public final Resource PipeRun; - public final Resource PipelineComponent; - public final Resource Plant; - public final Resource Plant3DProjectType; - public final Resource Reducer; - public final Resource RunEndControlPoint; - public final Resource SingleConnectedComponent; - public final Resource SizeChangeComponent; - public final Resource SizeChangeControlPoint; - public final Resource Straight; - public final Resource SubPointOf; - public final Resource TurnComponent; - public final Resource TurnControlPoint; - public final Resource UndirectedControlPoint; - public final Resource VariableAngleTurnComponent; - public final Resource VariableAngleTurnControlPoint; - public final Resource VariableLengthControlPoint; - public final Resource VariableLengthInlineComponent; - public final Resource VerticalVessel; - public final Resource Vessel; - - public static class URIs { - public static final String BranchControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#BranchControlPoint"; - public static final String BranchEndControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#BranchEndControlPoint"; - public static final String BranchSplitComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0#BranchSplitComponent"; - public static final String CodedComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#CodedComponent"; - public static final String ConcentricReducer = "http://www.vtt.fi/Simantics/Plant3D/1.0#ConcentricReducer"; - public static final String ControlPointOf = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#ControlPointOf"; - public static final String ControlPointOfPipeRun = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#ControlPointOfPipeRun"; - public static final String DirectedControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#DirectedControlPoint"; - public static final String DualConnectedComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#DualConnectedComponent"; - public static final String DualInlineControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#DualInlineControlPoint"; - public static final String DualSubControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#DualSubControlPoint"; - public static final String EccentricReducer = "http://www.vtt.fi/Simantics/Plant3D/1.0#EccentricReducer"; - public static final String Elbow = "http://www.vtt.fi/Simantics/Plant3D/1.0#Elbow"; - public static final String EndComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#EndComponent"; - public static final String EndComponentControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#EndComponentControlPoint"; - public static final String Equipment = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#Equipment"; - public static final String FixedAngleTurnComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#FixedAngleTurnComponent"; - public static final String FixedAngleTurnControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#FixedAngleTurnControlPoint"; - public static final String FixedLengthControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#FixedLengthControlPoint"; - public static final String FixedLengthInlineComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#FixedLengthInlineComponent"; - public static final String HasChildStructure = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasChildStructure"; - public static final String HasControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasControlPoint"; - public static final String HasControlPoints = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasControlPoints"; - public static final String HasGraphics = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasGraphics"; - public static final String HasHeight = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasHeight"; - public static final String HasLength = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasLength"; - public static final String HasNext = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasNext"; - public static final String HasNozzle = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasNozzle"; - public static final String HasNozzleDefinition = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasNozzleDefinition"; - public static final String HasNozzleRestriction = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasNozzleRestriction"; - public static final String HasOffset = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasOffset"; - public static final String HasParentStructure = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasParentStructure"; - public static final String HasPipeDiameter = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasPipeDiameter"; - public static final String HasPrevious = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasPrevious"; - public static final String HasRotationAngle = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasRotationAngle"; - public static final String HasSubPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasSubPoint"; - public static final String HasTurnAngle = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasTurnAngle"; - public static final String HasTurnAxis = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasTurnAxis"; - public static final String HasTurnRadius = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#HasTurnRadius"; - public static final String HorizontalVessel = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#HorizontalVessel"; - public static final String InlineComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#InlineComponent"; - public static final String InlineControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#InlineControlPoint"; - public static final String IsReversed = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#IsReversed"; - public static final String LibraryComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#LibraryComponent"; - public static final String MultiConnectedComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#MultiConnectedComponent"; - public static final String NPortControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#NPortControlPoint"; - public static final String NonVisibleComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#NonVisibleComponent"; - public static final String Nozzle = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#Nozzle"; - public static final String NozzleControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#NozzleControlPoint"; - public static final String NozzleOf = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#NozzleOf"; - public static final String OffsetComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#OffsetComponent"; - public static final String OffsettingPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#OffsettingPoint"; - public static final String P3DNode = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#P3DNode"; - public static final String PBSNode = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#PBSNode"; - public static final String PathLegEndControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#PathLegEndControlPoint"; - public static final String PipeControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#PipeControlPoint"; - public static final String PipeRun = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#PipeRun"; - public static final String PipelineComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#PipelineComponent"; - public static final String Plant = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#Plant"; - public static final String Plant3DProjectType = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#Plant3DProjectType"; - public static final String Reducer = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#Reducer"; - public static final String RunEndControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#RunEndControlPoint"; - public static final String SingleConnectedComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#SingleConnectedComponent"; - public static final String SizeChangeComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#SizeChangeComponent"; - public static final String SizeChangeControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#SizeChangeControlPoint"; - public static final String Straight = "http://www.vtt.fi/Simantics/Plant3D/1.0#Straight"; - public static final String SubPointOf = "http://www.vtt.fi/Simantics/Plant3D/1.0/Relations#SubPointOf"; - public static final String TurnComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#TurnComponent"; - public static final String TurnControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#TurnControlPoint"; - public static final String UndirectedControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#UndirectedControlPoint"; - public static final String VariableAngleTurnComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#VariableAngleTurnComponent"; - public static final String VariableAngleTurnControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#VariableAngleTurnControlPoint"; - public static final String VariableLengthControlPoint = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#VariableLengthControlPoint"; - public static final String VariableLengthInlineComponent = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#VariableLengthInlineComponent"; - public static final String VerticalVessel = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#VerticalVessel"; - public static final String Vessel = "http://www.vtt.fi/Simantics/Plant3D/1.0/Types#Vessel"; - } - - public Plant3DResource(Graph graph) throws Layer0MissingException { - try { - BranchControlPoint = graph.getResourceByURI(URIs.BranchControlPoint); - BranchEndControlPoint = graph.getResourceByURI(URIs.BranchEndControlPoint); - BranchSplitComponent = graph.getResourceByURI(URIs.BranchSplitComponent); - CodedComponent = graph.getResourceByURI(URIs.CodedComponent); - ConcentricReducer = graph.getResourceByURI(URIs.ConcentricReducer); - ControlPointOf = graph.getResourceByURI(URIs.ControlPointOf); - ControlPointOfPipeRun = graph.getResourceByURI(URIs.ControlPointOfPipeRun); - DirectedControlPoint = graph.getResourceByURI(URIs.DirectedControlPoint); - DualConnectedComponent = graph.getResourceByURI(URIs.DualConnectedComponent); - DualInlineControlPoint = graph.getResourceByURI(URIs.DualInlineControlPoint); - DualSubControlPoint = graph.getResourceByURI(URIs.DualSubControlPoint); - EccentricReducer = graph.getResourceByURI(URIs.EccentricReducer); - Elbow = graph.getResourceByURI(URIs.Elbow); - EndComponent = graph.getResourceByURI(URIs.EndComponent); - EndComponentControlPoint = graph.getResourceByURI(URIs.EndComponentControlPoint); - Equipment = graph.getResourceByURI(URIs.Equipment); - FixedAngleTurnComponent = graph.getResourceByURI(URIs.FixedAngleTurnComponent); - FixedAngleTurnControlPoint = graph.getResourceByURI(URIs.FixedAngleTurnControlPoint); - FixedLengthControlPoint = graph.getResourceByURI(URIs.FixedLengthControlPoint); - FixedLengthInlineComponent = graph.getResourceByURI(URIs.FixedLengthInlineComponent); - HasChildStructure = graph.getResourceByURI(URIs.HasChildStructure); - HasControlPoint = graph.getResourceByURI(URIs.HasControlPoint); - HasControlPoints = graph.getResourceByURI(URIs.HasControlPoints); - HasGraphics = graph.getResourceByURI(URIs.HasGraphics); - HasHeight = graph.getResourceByURI(URIs.HasHeight); - HasLength = graph.getResourceByURI(URIs.HasLength); - HasNext = graph.getResourceByURI(URIs.HasNext); - HasNozzle = graph.getResourceByURI(URIs.HasNozzle); - HasNozzleDefinition = graph.getResourceByURI(URIs.HasNozzleDefinition); - HasNozzleRestriction = graph.getResourceByURI(URIs.HasNozzleRestriction); - HasOffset = graph.getResourceByURI(URIs.HasOffset); - HasParentStructure = graph.getResourceByURI(URIs.HasParentStructure); - HasPipeDiameter = graph.getResourceByURI(URIs.HasPipeDiameter); - HasPrevious = graph.getResourceByURI(URIs.HasPrevious); - HasRotationAngle = graph.getResourceByURI(URIs.HasRotationAngle); - HasSubPoint = graph.getResourceByURI(URIs.HasSubPoint); - HasTurnAngle = graph.getResourceByURI(URIs.HasTurnAngle); - HasTurnAxis = graph.getResourceByURI(URIs.HasTurnAxis); - HasTurnRadius = graph.getResourceByURI(URIs.HasTurnRadius); - HorizontalVessel = graph.getResourceByURI(URIs.HorizontalVessel); - InlineComponent = graph.getResourceByURI(URIs.InlineComponent); - InlineControlPoint = graph.getResourceByURI(URIs.InlineControlPoint); - IsReversed = graph.getResourceByURI(URIs.IsReversed); - LibraryComponent = graph.getResourceByURI(URIs.LibraryComponent); - MultiConnectedComponent = graph.getResourceByURI(URIs.MultiConnectedComponent); - NPortControlPoint = graph.getResourceByURI(URIs.NPortControlPoint); - NonVisibleComponent = graph.getResourceByURI(URIs.NonVisibleComponent); - Nozzle = graph.getResourceByURI(URIs.Nozzle); - NozzleControlPoint = graph.getResourceByURI(URIs.NozzleControlPoint); - NozzleOf = graph.getResourceByURI(URIs.NozzleOf); - OffsetComponent = graph.getResourceByURI(URIs.OffsetComponent); - OffsettingPoint = graph.getResourceByURI(URIs.OffsettingPoint); - P3DNode = graph.getResourceByURI(URIs.P3DNode); - PBSNode = graph.getResourceByURI(URIs.PBSNode); - PathLegEndControlPoint = graph.getResourceByURI(URIs.PathLegEndControlPoint); - PipeControlPoint = graph.getResourceByURI(URIs.PipeControlPoint); - PipeRun = graph.getResourceByURI(URIs.PipeRun); - PipelineComponent = graph.getResourceByURI(URIs.PipelineComponent); - Plant = graph.getResourceByURI(URIs.Plant); - Plant3DProjectType = graph.getResourceByURI(URIs.Plant3DProjectType); - Reducer = graph.getResourceByURI(URIs.Reducer); - RunEndControlPoint = graph.getResourceByURI(URIs.RunEndControlPoint); - SingleConnectedComponent = graph.getResourceByURI(URIs.SingleConnectedComponent); - SizeChangeComponent = graph.getResourceByURI(URIs.SizeChangeComponent); - SizeChangeControlPoint = graph.getResourceByURI(URIs.SizeChangeControlPoint); - Straight = graph.getResourceByURI(URIs.Straight); - SubPointOf = graph.getResourceByURI(URIs.SubPointOf); - TurnComponent = graph.getResourceByURI(URIs.TurnComponent); - TurnControlPoint = graph.getResourceByURI(URIs.TurnControlPoint); - UndirectedControlPoint = graph.getResourceByURI(URIs.UndirectedControlPoint); - VariableAngleTurnComponent = graph.getResourceByURI(URIs.VariableAngleTurnComponent); - VariableAngleTurnControlPoint = graph.getResourceByURI(URIs.VariableAngleTurnControlPoint); - VariableLengthControlPoint = graph.getResourceByURI(URIs.VariableLengthControlPoint); - VariableLengthInlineComponent = graph.getResourceByURI(URIs.VariableLengthInlineComponent); - VerticalVessel = graph.getResourceByURI(URIs.VerticalVessel); - Vessel = graph.getResourceByURI(URIs.Vessel); - } catch(ResourceNotFoundException e) { - throw new Layer0MissingException(e); - } - } - - public static Plant3DResource getInstance(Graph graph) { - Session session = graph.getSession(); - Plant3DResource ret = session.getService(Plant3DResource.class); - if(ret == null) { - ret = new Plant3DResource(graph); - session.registerService(Plant3DResource.class, ret); - } - return ret; - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Reducer.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Reducer.java deleted file mode 100644 index a20f0815..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Reducer.java +++ /dev/null @@ -1,366 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class Reducer extends Entity implements IReducer { - - public Reducer(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public Reducer(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static Reducer createDefault(Graph graph) { - return new Reducer(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Reducer)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Reducer; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.CodedComponent toCodedComponent() { - return new org.simantics.processeditor.stubs.CodedComponent(graph, resource); - } - - public Reducer toReducer() { - return this; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.SizeChangeComponent toSizeChangeComponent() { - return new org.simantics.processeditor.stubs.SizeChangeComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.InlineComponent toInlineComponent() { - return new org.simantics.processeditor.stubs.InlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.DualConnectedComponent toDualConnectedComponent() { - return new org.simantics.processeditor.stubs.DualConnectedComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.FixedLengthInlineComponent toFixedLengthInlineComponent() { - return new org.simantics.processeditor.stubs.FixedLengthInlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/RunEndControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/RunEndControlPoint.java deleted file mode 100644 index a751e722..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/RunEndControlPoint.java +++ /dev/null @@ -1,269 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class RunEndControlPoint extends Entity implements IRunEndControlPoint { - - public RunEndControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public RunEndControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static RunEndControlPoint createDefault(Graph graph) { - return new RunEndControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).RunEndControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).RunEndControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.PathLegEndControlPoint toPathLegEndControlPoint() { - return new org.simantics.processeditor.stubs.PathLegEndControlPoint(graph, resource); - } - - public RunEndControlPoint toRunEndControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SingleConnectedComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SingleConnectedComponent.java deleted file mode 100644 index f174b772..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SingleConnectedComponent.java +++ /dev/null @@ -1,298 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class SingleConnectedComponent extends Entity implements ISingleConnectedComponent { - - public SingleConnectedComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public SingleConnectedComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static SingleConnectedComponent createDefault(Graph graph) { - return new SingleConnectedComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SingleConnectedComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SingleConnectedComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public SingleConnectedComponent toSingleConnectedComponent() { - return this; - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SizeChangeComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SizeChangeComponent.java deleted file mode 100644 index cd8eaf4d..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SizeChangeComponent.java +++ /dev/null @@ -1,354 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class SizeChangeComponent extends Entity implements ISizeChangeComponent { - - public SizeChangeComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public SizeChangeComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static SizeChangeComponent createDefault(Graph graph) { - return new SizeChangeComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SizeChangeComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SizeChangeComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public SizeChangeComponent toSizeChangeComponent() { - return this; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.InlineComponent toInlineComponent() { - return new org.simantics.processeditor.stubs.InlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.FixedLengthInlineComponent toFixedLengthInlineComponent() { - return new org.simantics.processeditor.stubs.FixedLengthInlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SizeChangeControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SizeChangeControlPoint.java deleted file mode 100644 index ca3db8e4..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/SizeChangeControlPoint.java +++ /dev/null @@ -1,325 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class SizeChangeControlPoint extends Entity implements ISizeChangeControlPoint { - - public SizeChangeControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public SizeChangeControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static SizeChangeControlPoint createDefault(Graph graph) { - return new SizeChangeControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SizeChangeControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SizeChangeControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.FixedLengthControlPoint toFixedLengthControlPoint() { - return new org.simantics.processeditor.stubs.FixedLengthControlPoint(graph, resource); - } - - public SizeChangeControlPoint toSizeChangeControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.DualInlineControlPoint toDualInlineControlPoint() { - return new org.simantics.processeditor.stubs.DualInlineControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.InlineControlPoint toInlineControlPoint() { - return new org.simantics.processeditor.stubs.InlineControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getRotationAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setRotationAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasRotationAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Straight.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Straight.java deleted file mode 100644 index 4a291986..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Straight.java +++ /dev/null @@ -1,338 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class Straight extends Entity implements IStraight { - - public Straight(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public Straight(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static Straight createDefault(Graph graph) { - return new Straight(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Straight)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Straight; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.CodedComponent toCodedComponent() { - return new org.simantics.processeditor.stubs.CodedComponent(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.InlineComponent toInlineComponent() { - return new org.simantics.processeditor.stubs.InlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.DualConnectedComponent toDualConnectedComponent() { - return new org.simantics.processeditor.stubs.DualConnectedComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.VariableLengthInlineComponent toVariableLengthInlineComponent() { - return new org.simantics.processeditor.stubs.VariableLengthInlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Straight toStraight() { - return this; - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/TurnComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/TurnComponent.java deleted file mode 100644 index a7bf3797..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/TurnComponent.java +++ /dev/null @@ -1,322 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class TurnComponent extends Entity implements ITurnComponent { - - public TurnComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public TurnComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static TurnComponent createDefault(Graph graph) { - return new TurnComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).TurnComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).TurnComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public TurnComponent toTurnComponent() { - return this; - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getTurnAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setTurnAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/TurnControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/TurnControlPoint.java deleted file mode 100644 index d50b67ff..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/TurnControlPoint.java +++ /dev/null @@ -1,317 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class TurnControlPoint extends Entity implements ITurnControlPoint { - - public TurnControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public TurnControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static TurnControlPoint createDefault(Graph graph) { - return new TurnControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).TurnControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).TurnControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.PathLegEndControlPoint toPathLegEndControlPoint() { - return new org.simantics.processeditor.stubs.PathLegEndControlPoint(graph, resource); - } - - public TurnControlPoint toTurnControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getTurnAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setTurnAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/UndirectedControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/UndirectedControlPoint.java deleted file mode 100644 index a15c73ca..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/UndirectedControlPoint.java +++ /dev/null @@ -1,273 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class UndirectedControlPoint extends Entity implements IUndirectedControlPoint { - - public UndirectedControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public UndirectedControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static UndirectedControlPoint createDefault(Graph graph) { - return new UndirectedControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).UndirectedControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).UndirectedControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.PathLegEndControlPoint toPathLegEndControlPoint() { - return new org.simantics.processeditor.stubs.PathLegEndControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.RunEndControlPoint toRunEndControlPoint() { - return new org.simantics.processeditor.stubs.RunEndControlPoint(graph, resource); - } - - public UndirectedControlPoint toUndirectedControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableAngleTurnComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableAngleTurnComponent.java deleted file mode 100644 index a5f904c8..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableAngleTurnComponent.java +++ /dev/null @@ -1,350 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class VariableAngleTurnComponent extends Entity implements IVariableAngleTurnComponent { - - public VariableAngleTurnComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public VariableAngleTurnComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static VariableAngleTurnComponent createDefault(Graph graph) { - return new VariableAngleTurnComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).VariableAngleTurnComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).VariableAngleTurnComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public VariableAngleTurnComponent toVariableAngleTurnComponent() { - return this; - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.TurnComponent toTurnComponent() { - return new org.simantics.processeditor.stubs.TurnComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getTurnRadius() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnRadius); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setTurnRadius(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnRadius; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getTurnAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setTurnAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableAngleTurnControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableAngleTurnControlPoint.java deleted file mode 100644 index a2a0584b..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableAngleTurnControlPoint.java +++ /dev/null @@ -1,362 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class VariableAngleTurnControlPoint extends Entity implements IVariableAngleTurnControlPoint { - - public VariableAngleTurnControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public VariableAngleTurnControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static VariableAngleTurnControlPoint createDefault(Graph graph) { - return new VariableAngleTurnControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).VariableAngleTurnControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).VariableAngleTurnControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.processeditor.stubs.PathLegEndControlPoint toPathLegEndControlPoint() { - return new org.simantics.processeditor.stubs.PathLegEndControlPoint(graph, resource); - } - - public VariableAngleTurnControlPoint toVariableAngleTurnControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.TurnControlPoint toTurnControlPoint() { - return new org.simantics.processeditor.stubs.TurnControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getTurnRadius() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnRadius); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setTurnRadius(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnRadius; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getTurnAngle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setTurnAngle(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAngle; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Tuple3 getTurnAxis() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAxis); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Tuple3(graph, statements[0].getObject()); - } - - public void addTurnAxis(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAxis, v.getResource()); - } - - public void setTurnAxis(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasTurnAxis; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableLengthControlPoint.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableLengthControlPoint.java deleted file mode 100644 index 3f0f2ac8..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableLengthControlPoint.java +++ /dev/null @@ -1,293 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class VariableLengthControlPoint extends Entity implements IVariableLengthControlPoint { - - public VariableLengthControlPoint(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public VariableLengthControlPoint(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static VariableLengthControlPoint createDefault(Graph graph) { - return new VariableLengthControlPoint(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).VariableLengthControlPoint)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).VariableLengthControlPoint; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public VariableLengthControlPoint toVariableLengthControlPoint() { - return this; - } - - public org.simantics.processeditor.stubs.InlineControlPoint toInlineControlPoint() { - return new org.simantics.processeditor.stubs.InlineControlPoint(graph, resource); - } - - public org.simantics.processeditor.stubs.PipeControlPoint toPipeControlPoint() { - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, resource); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getNext() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addNext(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext, v.getResource()); - } - - public void setNext(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNext; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getPrevious() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addPrevious(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious, v.getResource()); - } - - public void setPrevious(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPrevious; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public Collection getSubPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PipeControlPoint(graph, s.getObject())); - return ret; - } - - public void addSubPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasSubPoint, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getSubPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addSubPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf, v.getResource()); - } - - public void setSubPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).SubPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public org.simantics.layer0.utils.IEntity getControlPointOf() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new Entity(graph, statements[0].getObject()); - } - - // [Nozzle] | [Pipeline Component] - public void addControlPointOf(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf, v.getResource()); - } - - // [Nozzle] | [Pipeline Component] - public void setControlPointOf(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOf; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PipeRun getControlPointOfPipeRun() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeRun(graph, statements[0].getObject()); - } - - public void addControlPointOfPipeRun(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun, v.getResource()); - } - - public void setControlPointOfPipeRun(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).ControlPointOfPipeRun; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableLengthInlineComponent.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableLengthInlineComponent.java deleted file mode 100644 index d830467c..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VariableLengthInlineComponent.java +++ /dev/null @@ -1,326 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class VariableLengthInlineComponent extends Entity implements IVariableLengthInlineComponent { - - public VariableLengthInlineComponent(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public VariableLengthInlineComponent(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static VariableLengthInlineComponent createDefault(Graph graph) { - return new VariableLengthInlineComponent(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).VariableLengthInlineComponent)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).VariableLengthInlineComponent; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.InlineComponent toInlineComponent() { - return new org.simantics.processeditor.stubs.InlineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public VariableLengthInlineComponent toVariableLengthInlineComponent() { - return this; - } - - public org.simantics.processeditor.stubs.PipelineComponent toPipelineComponent() { - return new org.simantics.processeditor.stubs.PipelineComponent(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public double[] getPipeDiameter() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setPipeDiameter(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasPipeDiameter; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getLength() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setLength(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasLength; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public org.simantics.processeditor.stubs.PipeControlPoint getControlPoint() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PipeControlPoint(graph, statements[0].getObject()); - } - - public void addControlPoint(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint, v.getResource()); - } - - public void setControlPoint(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasControlPoint; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VerticalVessel.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VerticalVessel.java deleted file mode 100644 index 071ada35..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/VerticalVessel.java +++ /dev/null @@ -1,342 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class VerticalVessel extends Entity implements IVerticalVessel { - - public VerticalVessel(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public VerticalVessel(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static VerticalVessel createDefault(Graph graph) { - return new VerticalVessel(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).VerticalVessel)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).VerticalVessel; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public VerticalVessel toVerticalVessel() { - return this; - } - - public org.simantics.processeditor.stubs.Vessel toVessel() { - return new org.simantics.processeditor.stubs.Vessel(graph, resource); - } - - public org.simantics.processeditor.stubs.Equipment toEquipment() { - return new org.simantics.processeditor.stubs.Equipment(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.Nozzle getNozzle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.Nozzle(graph, statements[0].getObject()); - } - - public void addNozzle(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle, v.getResource()); - } - - public void setNozzle(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle]&[Property] - public Collection getNozzleDefinition() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleDefinition); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new Entity(graph, s.getObject())); - return ret; - } - - // [Nozzle]&[Property] - public void addNozzleDefinition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleDefinition, v.getResource()); - } - - public String[] getNozzleRestriction() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleRestriction); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return (String[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setNozzleRestriction(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleRestriction; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).IntegerRangeUnion; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - - public double[] getHeight() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasHeight); - if(statements.length != 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - return (double[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setHeight(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasHeight; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).Double; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Vessel.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Vessel.java deleted file mode 100644 index 3ed003a4..00000000 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/stubs/Vessel.java +++ /dev/null @@ -1,314 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.processeditor.stubs; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceContainer; -import org.simantics.db.Statement; -import org.simantics.db.Graph; -import org.simantics.db.ResourceContainer; -import org.simantics.layer0.utils.ResourceDoesNotSatisfyAssumptionException; -import org.simantics.layer0.utils.IEntity; -import org.simantics.layer0.utils.internal.Entity; -import org.simantics.layer0.utils.instantiation.InstanceFactory; -import java.util.Collection; -import java.util.ArrayList; - -public class Vessel extends Entity implements IVessel { - - public Vessel(Graph graph, ResourceContainer resourceContainer) { - super(graph, resourceContainer.getResource()); - } - - public Vessel(IEntity entity) { - super(entity.getGraph(), entity.getResource()); - } - - public Graph getGraph() { - return graph; - } - - public static Vessel createDefault(Graph graph) { - return new Vessel(graph, InstanceFactory.instantiate(graph, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Vessel)); - } - - public static boolean isInstance(IEntity entity) { - Graph graph = entity.getGraph(); - Resource type = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).Vessel; - return graph.isInstanceOf(entity.getResource(), type); - } - - @Override - public Resource getResource() { - return resource; - } - - public org.simantics.proconf.g3d.stubs.G3DNode toG3DNode() { - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, resource); - } - - public org.simantics.processeditor.stubs.PBSNode toPBSNode() { - return new org.simantics.processeditor.stubs.PBSNode(graph, resource); - } - - public org.simantics.processeditor.stubs.P3DNode toP3DNode() { - return new org.simantics.processeditor.stubs.P3DNode(graph, resource); - } - - public Vessel toVessel() { - return this; - } - - public org.simantics.processeditor.stubs.Equipment toEquipment() { - return new org.simantics.processeditor.stubs.Equipment(graph, resource); - } - - public org.simantics.processeditor.stubs.LibraryComponent toLibraryComponent() { - return new org.simantics.processeditor.stubs.LibraryComponent(graph, resource); - } - - public Collection getChild() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.proconf.g3d.stubs.G3DNode(graph, s.getObject())); - return ret; - } - - public void addChild(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasChild, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DNode getParent() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DNode(graph, statements[0].getObject()); - } - - public void addParent(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent, v.getResource()); - } - - public void setParent(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasParent; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getLocalPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addLocalPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition, v.getResource()); - } - - public void setLocalPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Position getWorldPosition() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Position(graph, statements[0].getObject()); - } - - public void addWorldPosition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition, v.getResource()); - } - - public void setWorldPosition(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldPosition; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getLocalOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addLocalOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation, v.getResource()); - } - - public void setLocalOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasLocalOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Orientation getWorldOrientation() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Orientation(graph, statements[0].getObject()); - } - - public void addWorldOrientation(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation, v.getResource()); - } - - public void setWorldOrientation(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasWorldOrientation; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.Center getCenter() { - Statement[] statements = graph.getStatements(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.Center(graph, statements[0].getObject()); - } - - public void addCenter(ResourceContainer v) { - graph.addStatement(resource, org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter, v.getResource()); - } - - public void setCenter(ResourceContainer v) { - Resource predicate = org.simantics.proconf.g3d.stubs.G3DResource.getInstance(graph).HasCenter; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.PBSNode getParentStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.PBSNode(graph, statements[0].getObject()); - } - - public void addParentStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure, v.getResource()); - } - - public void setParentStructure(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasParentStructure; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public Collection getChildStructure() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new org.simantics.processeditor.stubs.PBSNode(graph, s.getObject())); - return ret; - } - - public void addChildStructure(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasChildStructure, v.getResource()); - } - - public org.simantics.proconf.g3d.stubs.G3DModel getGraphics() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.proconf.g3d.stubs.G3DModel(graph, statements[0].getObject()); - } - - public void addGraphics(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics, v.getResource()); - } - - public void setGraphics(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasGraphics; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - public org.simantics.processeditor.stubs.Nozzle getNozzle() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return new org.simantics.processeditor.stubs.Nozzle(graph, statements[0].getObject()); - } - - public void addNozzle(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle, v.getResource()); - } - - public void setNozzle(ResourceContainer v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzle; - graph.removeStatements(resource, predicate); - graph.addStatement(resource, predicate, v.getResource()); - } - - // [Nozzle]&[Property] - public Collection getNozzleDefinition() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleDefinition); - Collection ret = new ArrayList(statements.length); - for(Statement s : statements) - ret.add(new Entity(graph, s.getObject())); - return ret; - } - - // [Nozzle]&[Property] - public void addNozzleDefinition(ResourceContainer v) { - graph.addStatement(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleDefinition, v.getResource()); - } - - public String[] getNozzleRestriction() { - Statement[] statements = graph.getStatements(resource, org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleRestriction); - if(statements.length > 1) - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + statements.length + ") of statements."); - if(statements.length == 0) - return null; - return (String[])graph.getValueAsObject(statements[0].getObject()); - } - - public void setNozzleRestriction(Object v) { - Resource predicate = org.simantics.processeditor.stubs.Plant3DResource.getInstance(graph).HasNozzleRestriction; - Collection objects = graph.getObjects(resource, predicate); - if(objects.size() == 0) { - Resource r = graph.newResource(); - Resource valueType = org.simantics.db.Builtins.getInstance(graph).IntegerRangeUnion; - graph.addStatement(r, graph.getBuiltins().InstanceOf, valueType); - graph.setValueAsObject(r, v); - graph.addStatement(resource, predicate, r); - } - else if(objects.size() == 1) - for(Resource r : objects) - graph.setValueAsObject(r, v); - else - throw new ResourceDoesNotSatisfyAssumptionException("Wrong number (" + objects.size() + ") of statements."); - } - -} - -- 2.47.1