1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.jfreechart.chart.properties;
\r
14 import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;
\r
15 import org.simantics.databoard.Bindings;
\r
16 import org.simantics.db.ReadGraph;
\r
17 import org.simantics.db.Resource;
\r
18 import org.simantics.db.common.request.PossibleObjectWithType;
\r
19 import org.simantics.db.exception.DatabaseException;
\r
20 import org.simantics.layer0.Layer0;
\r
21 import org.simantics.sysdyn.JFreeChartResource;
\r
24 * TextFactory for chart title
\r
25 * @author Teemu Lempinen
\r
28 public class TitleFactory extends ReadFactoryImpl<Resource, String> {
\r
30 public String perform(ReadGraph graph, Resource chart) throws DatabaseException {
\r
31 Layer0 l0 = Layer0.getInstance(graph);
\r
32 JFreeChartResource jfree = JFreeChartResource.getInstance(graph);
\r
33 Resource title = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.TextTitle));
\r
37 String label = graph.getPossibleRelatedValue(title, l0.HasLabel, Bindings.STRING);
\r
38 return label == null ? "" : label;
\r