Formato Visio Pagine

Aspose.Diagram for Java API consente agli sviluppatori di formattare le pagine di un file Visio Diagram. L’applicazione dei fogli di stile è uno di questi metodi per formattare le pagine Visio.

Applica i fogli di stile alla pagina Visio

Aspose.Diagram for Java API consente di formattare una pagina Visio utilizzando i fogli di stile. È possibile definire un foglio di stile e aggiungerlo alla raccolta di fogli di stile del documento Visio. Il metodo ApplyStyle della classe Page consente di applicare il foglio di stile definito alla pagina, come illustrato nell’esempio di codice seguente.

// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(ReadDiagramFile.class) + "Diagrams/";
// Open the stream. Read only access is enough for Aspose.Diagram to
// load a diagram.
InputStream stream = new FileInputStream(dataDir + "ReadDiagramFile.vsd");
// load diagram
Diagram vsdDiagram = new Diagram(stream);
//Define a new StyleSheet
StyleSheet st = new StyleSheet();
st.setID(vsdDiagram.getStyleSheets().getCount()+1);
com.aspose.diagram.Char ch = new com.aspose.diagram.Char();
ch.getColor().setValue("#00ff00");
ch.setIX(0);
st.getChars().add(ch);
st.getLine().getLineColor().setValue("#ff0000");
st.getLine().getLinePattern().setValue(1);
st.getLine().getLineWeight().setValue(0.01);
st.getFill().getFillForegnd().setValue("#0000ff");
st.getFill().getFillPattern().setValue(1);
st.getFill().getShdwPattern().setValue(0);
//Add the stylesheet to Stylesheets collection
vsdDiagram.getStyleSheets().add(st);
for (Shape shape: (Iterable<Shape>)vsdDiagram.getPages().get(0).getShapes())
{
shape.getLine().getLinePattern().setValue(1);
shape.getFill().getFillPattern().setValue(1);
}
//Apply the stylesheet
vsdDiagram.getPages().get(0).applyStyle(st.getID(), st.getID(), st.getID());