이 문서에서는 Java에서 순서도를 만드는 방법에 대해 설명합니다. 여기에는 Java에서 순서도 작성기를 개발하기 위한 단계별 알고리즘과 실행 가능한 코드 조각이 포함되어 있습니다. 또한 스키마, 모양 수, 연결 및 기타 속성을 조작하여 요구 사항에 따라 flowchart을 생성함으로써 프로세스를 향상시킬 수 있습니다.
Java에서 순서도를 만드는 단계
- 흐름도 생성을 위한 Aspose.Diagram API를 설치하여 환경을 준비합니다.
- 순서도에 대한 스키마 개발
- Diagram 클래스의 개체를 만들고 모양 삽입을 위한 마스터 모양을 로드합니다.
- 플로우차트의 레이아웃을 설정하고 save Save 메소드를 사용하여 생성된 플로우차트를 내보냅니다.
이 단계에서는 Java에서 *흐름도 생성기를 개발하는 프로세스를 보여줍니다. 먼저 다양한 역할, 지정 및 기타 속성을 설정하기 위한 스키마를 만듭니다. 그런 다음 레이아웃을 설정하고 출력 순서도를 저장하기 전에 마스터 모양을 사용하여 직사각형, 연결선 등과 같은 다양한 모양을 추가합니다.
Java에서 순서도 생성기를 생성하는 코드
import com.aspose.diagram.*; | |
public class Main | |
{ | |
public static void main(String[] args) throws Exception // Create flowchart in Java | |
{ | |
// Set the licenses | |
new License().setLicense("License.lic"); | |
// Create a new diagram | |
int pageNumber = 0; | |
String MasterRectangle = "Process", decisionMaster = "Decision", connectorMaster = "Dynamic connector"; | |
com.aspose.diagram.Diagram diagram = new com.aspose.diagram.Diagram("XANFLOWCHARTNEW.vss"); | |
double widthparam = 1, heightparam = 1, pinX = 4, pinY = 10; | |
long process1 = diagram.addShape(pinX, pinY, widthparam, heightparam, MasterRectangle, 0); | |
Shape processShape1 = diagram.getPages().getPage(pageNumber).getShapes().getShape(process1); | |
processShape1.getText().getValue().add(new Txt("PROCESS")); | |
processShape1.setName("PROCESS"); | |
processShape1.getXForm().getLocPinX().getUfe().setF("Width*0.5"); | |
processShape1.getXForm().getLocPinY().getUfe().setF("Height*0.5"); | |
pinY = pinY - 2; | |
long decision1 = diagram.addShape(pinX, pinY, widthparam, heightparam, decisionMaster, 0); | |
Shape decisionShape1 = diagram.getPages().getPage(pageNumber).getShapes().getShape(decision1); | |
decisionShape1.getText().getValue().add(new Txt("DECISION")); | |
decisionShape1.setName("DECISION"); | |
decisionShape1.getXForm().getLocPinX().getUfe().setF("Width*0.5"); | |
decisionShape1.getXForm().getLocPinY().getUfe().setF("Height*0.5"); | |
pinY = pinY - 2; | |
long process2 = diagram.addShape(pinX, pinY, widthparam, heightparam, MasterRectangle, 0); | |
Shape processShape2 = diagram.getPages().getPage(pageNumber).getShapes().getShape(process2); | |
processShape2.getText().getValue().add(new Txt("PROCESS")); | |
processShape2.setName("PROCESS"); | |
processShape2.getXForm().getLocPinX().getUfe().setF("Width*0.5"); | |
processShape2.getXForm().getLocPinY().getUfe().setF("Height*0.5"); | |
pinY = pinY - 2; | |
long process3 = diagram.addShape(pinX, pinY, widthparam, heightparam, MasterRectangle, 0); | |
Shape processShape3 = diagram.getPages().getPage(pageNumber).getShapes().getShape(process3); | |
processShape3.getText().getValue().add(new Txt("PROCESS")); | |
processShape3.setName("PROCESS"); | |
processShape3.getXForm().getLocPinX().getUfe().setF("Width*0.5"); | |
processShape3.getXForm().getLocPinY().getUfe().setF("Height*0.5"); | |
pinY = pinY - 2; | |
long process4 = diagram.addShape(pinX, pinY, widthparam, heightparam, MasterRectangle, 0); | |
Shape processShape4 = diagram.getPages().getPage(pageNumber).getShapes().getShape(process4); | |
processShape4.getText().getValue().add(new Txt("PROCESS")); | |
processShape4.setName("PROCESS"); | |
processShape4.getXForm().getLocPinX().getUfe().setF("Width*0.5"); | |
processShape4.getXForm().getLocPinY().getUfe().setF("Height*0.5"); | |
long connecterId = diagram.addShape(new Shape(), connectorMaster, 0); | |
diagram.getPages().getPage(pageNumber).connectShapesViaConnector(process1, ConnectionPointPlace.BOTTOM, | |
decision1, ConnectionPointPlace.TOP, connecterId); | |
long connecterId1 = diagram.addShape(new Shape(), connectorMaster, 0); | |
diagram.getPages().getPage(pageNumber).connectShapesViaConnector(decision1, ConnectionPointPlace.BOTTOM, | |
process2, ConnectionPointPlace.TOP, connecterId1); | |
long connecterId2 = diagram.addShape(new Shape(), connectorMaster, 0); | |
diagram.getPages().getPage(pageNumber).connectShapesViaConnector(process2, ConnectionPointPlace.BOTTOM, | |
process3, ConnectionPointPlace.TOP, connecterId2); | |
long connecterId3 = diagram.addShape(new Shape(), connectorMaster, 0); | |
diagram.getPages().getPage(pageNumber).connectShapesViaConnector(process3, ConnectionPointPlace.BOTTOM, | |
process4, ConnectionPointPlace.TOP, connecterId3); | |
long connecterId4 = diagram.addShape(new Shape(), connectorMaster, 0); | |
diagram.getPages().getPage(pageNumber).connectShapesViaConnector(decision1, ConnectionPointPlace.RIGHT, | |
process4, ConnectionPointPlace.TOP, connecterId4); | |
// Set automatic layout options | |
com.aspose.diagram.LayoutOptions layoutOptions = new com.aspose.diagram.LayoutOptions(); | |
layoutOptions.setLayoutStyle(com.aspose.diagram.LayoutStyle.FLOW_CHART); | |
layoutOptions.setDirection(com.aspose.diagram.LayoutDirection.BOTTOM_TO_TOP); diagram.layout(layoutOptions); | |
com.aspose.diagram.DiagramSaveOptions options = new com.aspose.diagram.DiagramSaveOptions(com.aspose.diagram.SaveFileFormat.VSDX); | |
diagram.save( "flowchart.vsdx", options); | |
System.out.println("Done"); | |
} | |
} |
이 코드 조각은 Java에서 순서도를 그리는 기본 버전입니다. Diagram 클래스는 일부 마스터 모양을 로드하고 레이아웃을 지정하고 출력 순서도를 내보내는 데 사용됩니다. 그러나 일부 사용자 정의 클래스는 다양한 커넥터와 다양한 모양을 만드는 데에도 사용되며, 이는 요구 사항을 충족하기 위해 즉석에서 추가로 만들 수 있습니다.
이 튜토리얼에서는 Java에서 순서도 빌더를 만들기 위한 정보를 컴파일했습니다. 게다가 이미지를 Visio 다이어그램으로 변환해야 하는 경우 Java에서 이미지를 Visio로 변환하는 방법의 기사를 참조하세요.