// write cluster layout with attributes static void write_ogml_layout(const ClusterGraphAttributes &A, ostream &os) { const ClusterGraph &C = A.constClusterGraph(); GraphIO::indent(os,2) << "<layout>\n"; GraphIO::indent(os,3) << "<styles>\n"; for(cluster c : C.clusters) { if(c != C.rootCluster()) { GraphIO::indent(os,4) << "<nodeStyle idRef=\"c" << c->index() << "\">\n"; GraphIO::indent(os,5) << "<location x=\"" << A.x(c) << "\" y=\"" << A.y(c) << "\" />\n"; GraphIO::indent(os,5) << "<shape type=\"rect\" width=\"" << A.width(c) << "\" height=\"" << A.height(c) << "\" />\n"; GraphIO::indent(os,5) << "<fill color=\"" << A.fillColor(c) << "\"" << " pattern=\"" << fillPatternToOGML(A.fillPattern(c)) << "\" patternColor=\"" << A.fillBgColor(c) << "\" />\n"; GraphIO::indent(os,5) << "<line type=\"" << edgeStyleToOGML(A.strokeType(c)) << "\" width=\"" << A.strokeWidth(c) << "\" color=\"" << A.strokeColor(c) << "\" />\n"; GraphIO::indent(os,4) << "</nodeStyle>\n"; } } write_ogml_layout_nodes_edges(A,os); GraphIO::indent(os,3) << "</styles>\n"; GraphIO::indent(os,2) << "</layout>\n"; }
bool GmlParser::readClusterAttributes( GmlObject* cGraphics, cluster c, ClusterGraphAttributes& ACG) { string label; string fill; // the fill color attribute string line; // the line color attribute float lineWidth = 1.0f; //node line width int pattern = 1; //node brush pattern int stipple = 1; //line style pattern // read all relevant attributes GmlObject *graphicsObject = cGraphics->m_pFirstSon; for(; graphicsObject; graphicsObject = graphicsObject->m_pBrother) { switch(id(graphicsObject)) { case xPredefKey: if(graphicsObject->m_valueType != gmlDoubleValue) return false; ACG.x(c) = graphicsObject->m_doubleValue; break; case yPredefKey: if(graphicsObject->m_valueType != gmlDoubleValue) return false; ACG.y(c) = graphicsObject->m_doubleValue; break; case widthPredefKey: if(graphicsObject->m_valueType != gmlDoubleValue) return false; ACG.width(c) = graphicsObject->m_doubleValue; break; case heightPredefKey: if(graphicsObject->m_valueType != gmlDoubleValue) return false; ACG.height(c) = graphicsObject->m_doubleValue; break; case fillPredefKey: if(graphicsObject->m_valueType != gmlStringValue) return false; ACG.fillColor(c) = graphicsObject->m_stringValue; break; case patternPredefKey: if(graphicsObject->m_valueType != gmlIntValue) return false; pattern = graphicsObject->m_intValue; break; //line style case colorPredefKey: // line color if(graphicsObject->m_valueType != gmlStringValue) return false; ACG.strokeColor(c) = graphicsObject->m_stringValue; break; case stipplePredefKey: if(graphicsObject->m_valueType != gmlIntValue) return false; stipple = graphicsObject->m_intValue; break; case lineWidthPredefKey: if(graphicsObject->m_valueType != gmlDoubleValue) return false; lineWidth = (float)graphicsObject->m_doubleValue; break; //TODO: backgroundcolor //case stylePredefKey: //case boderwidthPredefKey: }//switch }//for //Hier eigentlich erst abfragen, ob clusterattributes setzbar in ACG, //dann setzen ACG.setStrokeType(c, intToStrokeType(stipple)); //defaulting 1 ACG.strokeWidth(c) = lineWidth; ACG.setFillPattern(c, intToFillPattern(pattern)); return true; }//readclusterattributes