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.TextModifyListenerImpl;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.db.WriteGraph;
\r
17 import org.simantics.db.common.request.PossibleObjectWithType;
\r
18 import org.simantics.db.exception.DatabaseException;
\r
19 import org.simantics.layer0.Layer0;
\r
20 import org.simantics.layer0.utils.direct.GraphUtils;
\r
21 import org.simantics.sysdyn.JFreeChartResource;
\r
24 * TitleModifier for chart title
\r
25 * @author Teemu Lempinen
\r
28 public class TitleModifier extends TextModifyListenerImpl<Resource> {
\r
31 public void applyText(WriteGraph graph, Resource chart, String text) throws DatabaseException {
\r
32 Layer0 l0 = Layer0.getInstance(graph);
\r
33 JFreeChartResource jfree = JFreeChartResource.getInstance(graph);
\r
34 Resource title = graph.syncRequest(new PossibleObjectWithType(chart, l0.ConsistsOf, jfree.TextTitle));
\r
36 title = GraphUtils.create2(graph, jfree.TextTitle,
\r
37 jfree.Title_position, jfree.Top);
\r
39 graph.claimLiteral(title, l0.HasLabel, text);
\r