In some cases, negative numbers are written as "△ 100,000" in accounting materials. Yellowfin can achieve this with ** Custom Formatter **.
** Yellowfin plugins ** such as custom formatters are developed in Java. This time, I am using Eclipse (Pleiades which is a Japanese version of Eclipse).
The development method is described in Yellowfin's online manual. Basics of plugin development Creating a custom formatter In this article, we will proceed while folding, so please refer to the manual as appropriate.
Create a new Java project. Even if the Java version is 7, it is written in the manual, so JRE should select java7. ..
Click Next and change the Default Output Folder to **
Right-click on the project and select Import.
Select File System and click Next.
** Go to
Select everything under ROOT and check the "Create links in workspace" checkbox in the "Extended" item.
Right-click on the project and select Build Path> Configure Build Path from the menu.
Click Library.
Click the Add JAR button and enter i4 in the search bar. Select "i4-core.jar" and "i4-mi.jar" from the search results.
Create a new folder with the name ** META-INF ** under the src folder. Create a new folder named ** services ** under that folder.
Create a file called ** com.hof.mi.interfaces.CustomFormatter ** under the services folder.
Write com.company.yellowfin.formatters.SankakuFormatter
in the created file. This will be the fully qualified class name of the custom formatter you create.
Right-click on the project and select New> Package. Name the new package ** com.company.yellowfin.formatters **. (Match with the fully qualified class name you set earlier)
Right-click on the package you created and select New> File. The file name is ** SankakuFormatter.java **. (This is also combined with the fully qualified class name)
Paste the following code into SankakuFormatter.java.
SankakuFormatter.java
package com.company.yellowfin.formatters;
import java.text.NumberFormat;
import com.hof.mi.interfaces.CustomFormatter;
public class SankakuFormatter extends CustomFormatter {
public String getName() {
return "Triangular formatter";
}
public boolean acceptsNativeType(int type) {
// We only handle numeric types
if (type == TYPE_NUMERIC) return true;
return false;
}
public String render(Object value, int renderType) throws Exception {
if (value == null) return null;
if (renderType == RENDER_LINK) {
// Return a generic version of the value
return value.toString();
}
// Create a String representing the value
NumberFormat nf = NumberFormat.getNumberInstance();
String mark = "";
String valStr = value.toString();
double valNum = Double.parseDouble(valStr);
double val = valNum;
if (valNum < 0 ) {
mark = "△";
val = Math.abs(val);
}
return mark + nf.format(val);
}
}
By the way, the code example that I referred to is in the online manual.
Right-click on the project and select Export.
Select "JAR File".
Select all ** except ** .settings and ROOT, specify the JAR file name (here ** SankakuFormatter.jar **) and export.
From the Yellowfin plugin management screen, add the created JAR file as a new plugin.
The custom formatter created this time is named ** Triangle Formatter **. The name is specified in ** getName () ** in SankakuFormatter.java. This formatter allows you to format negative numbers with the "△" symbol.
For example, suppose you have the following simple data.
For this number, specify "triangular formatter" in the format.
Then, the negative number is displayed as a triangle symbol!
At first glance, it may seem that the string has been modified to have a symbol, but in reality, the data itself remains a numeric type just by changing the apparent format, so it is possible to apply conditional formatting.
I put the created JAR file on Github. Please use it if you like! https://github.com/hadatuna/SankakuFormatter
Recommended Posts