コード例 #1
0
bool GmlParser::readClusterAttributes(GmlObject* cGraphics,
									  cluster c,
									  ClusterGraphAttributes& ACG
									  )
{
	String label;
	String fill;  // the fill color attribute
	String line;  // the line color attribute
	double lineWidth = 1.0; //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.clusterXPos(c) = graphicsObject->m_doubleValue;
				break;

			case yPredefKey:
				if(graphicsObject->m_valueType != gmlDoubleValue) return false;
				ACG.clusterYPos(c) = graphicsObject->m_doubleValue;
				break;

			case widthPredefKey:
				if(graphicsObject->m_valueType != gmlDoubleValue) return false;
				ACG.clusterWidth(c) = graphicsObject->m_doubleValue;
				break;

			case heightPredefKey:
				if(graphicsObject->m_valueType != gmlDoubleValue) return false;
				ACG.clusterHeight(c) = graphicsObject->m_doubleValue;
				break;
			case fillPredefKey:
				if(graphicsObject->m_valueType != gmlStringValue) return false;
                ACG.clusterFillColor(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.clusterColor(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 = 
					graphicsObject->m_doubleValue;
				break;
			//TODO: backgroundcolor
			//case stylePredefKey:
			//case boderwidthPredefKey:
		}//switch
	}//for

	//Hier eigentlich erst abfragen, ob clusterattributes setzbar in ACG,
	//dann setzen
	ACG.clusterLineStyle(c) = GraphAttributes::intToStyle(stipple); //defaulting 1
	ACG.clusterLineWidth(c) = lineWidth;
	ACG.clusterFillPattern(c) = GraphAttributes::intToPattern(pattern);

	return true;
}//readclusterattributes