use of com.google.cloud.vision.v1p3beta1.Image in project ovirt-engine by oVirt.
the class OpenStackImageProviderProxy method getAllImagesAsRepoImages.
public List<RepoImage> getAllImagesAsRepoImages(Integer listSize, Integer totalListSize) {
ArrayList<RepoImage> repoImages = new ArrayList<>();
long currentTime = System.currentTimeMillis();
Images images = null;
do {
OpenStackRequest<Images> listRequest = getClient().images().list(true).queryParam("limit", listSize).queryParam("sort_key", "name").queryParam("sort_dir", "asc");
if (images != null) {
listRequest.queryParam("marker", images.getList().get(images.getList().size() - 1).getId());
}
images = listRequest.execute();
for (Image glanceImage : images) {
RepoImage repoImage = imageToRepoImage(glanceImage);
repoImage.setLastRefreshed(currentTime);
repoImages.add(repoImage);
}
} while (images.getList().size() >= listSize && totalListSize != null && repoImages.size() < totalListSize);
return repoImages;
}
use of com.google.cloud.vision.v1p3beta1.Image in project hortonmachine by TheHortonMachine.
the class GeopaparazziController method init.
@SuppressWarnings({ "serial" })
private void init() {
_infoArea = new JTextPane();
// _infoArea.setDocument(new SqlDocument());
_infoArea.setContentType("text/html");
_infoArea.setEditable(false);
_infoScroll.setViewportView(_infoArea);
// _infoScroll.setMinimumSize(new Dimension(10, 200));
_chartHolder.setLayout(new BorderLayout());
_loadFolderButton.setIcon(ImageCache.getInstance().getImage(ImageCache.REFRESH));
_loadFolderButton.setText("");
_loadFolderButton.setPreferredSize(preferredButtonSize);
_loadFolderButton.addActionListener(e -> {
final File geopaparazziFolder = new File(_projectsFolderTextfield.getText());
if (!geopaparazziFolder.exists()) {
GuiUtilities.showWarningMessage(this, null, "The projects folder doesn't exist.");
return;
}
File[] projectFiles = GeopaparazziUtilities.getGeopaparazziFiles(geopaparazziFolder);
try {
projectInfos = readProjectInfos(projectFiles);
layoutTree(projectInfos, false);
_filterTextfield.setText("");
} catch (Exception e1) {
Logger.INSTANCE.insertError("", "error", e1);
}
});
_projectsFolderBrowseButton.setPreferredSize(preferredButtonSize);
_projectsFolderBrowseButton.addActionListener(e -> {
File[] openFiles = guiBridge.showOpenDirectoryDialog("Open projects folder", PreferencesHandler.getLastFile());
if (openFiles != null && openFiles.length > 0) {
try {
PreferencesHandler.setLastPath(openFiles[0].getAbsolutePath());
} catch (Exception e1) {
Logger.INSTANCE.insertError("", "ERROR", e1);
}
} else {
return;
}
_projectsFolderTextfield.setText(openFiles[0].getAbsolutePath());
});
String lastSavedPath = prefsMap.get(GuiBridgeHandler.LAST_GP_PROJECTS_PATH);
_projectsFolderTextfield.setText(lastSavedPath);
_filterTextfield.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
String filterText = _filterTextfield.getText().toLowerCase();
final List<ProjectInfo> filtered = new ArrayList<ProjectInfo>();
if (filterText == null) {
filtered.addAll(projectInfos);
} else {
for (ProjectInfo projectInfo : projectInfos) {
if (projectInfo.fileName.toLowerCase().contains(filterText) || projectInfo.metadata.toLowerCase().contains(filterText)) {
filtered.add(projectInfo);
}
}
}
layoutTree(filtered, false);
}
});
addComponentListener(new ComponentListener() {
public void componentShown(ComponentEvent e) {
}
public void componentResized(ComponentEvent e) {
}
public void componentMoved(ComponentEvent e) {
}
public void componentHidden(ComponentEvent e) {
onClose();
}
});
try {
_databaseTreeView.setMinimumSize(new Dimension(300, 200));
addJtreeDragNDrop();
addJtreeContextMenu();
_databaseTree.setRootVisible(false);
_databaseTree.setCellRenderer(new DefaultTreeCellRenderer() {
@Override
public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof ProjectInfo) {
setIcon(ImageCache.getInstance().getImage(ImageCache.DATABASE));
} else if (value instanceof Image) {
setIcon(ImageCache.getInstance().getImage(ImageCache.DBIMAGE));
} else if (value instanceof GpsLog) {
setIcon(ImageCache.getInstance().getImage(ImageCache.GEOM_LINE));
} else if (value instanceof Note) {
setIcon(ImageCache.getInstance().getImage(ImageCache.NOTE));
}
return this;
}
});
_databaseTree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent evt) {
TreePath[] paths = evt.getPaths();
currentSelectedProject = null;
currentSelectedImage = null;
currentSelectedNote = null;
currentSelectedGpsLog = null;
_chartHolder.removeAll();
if (paths.length > 0) {
Object selectedItem = paths[0].getLastPathComponent();
if (selectedItem instanceof ProjectInfo) {
currentSelectedProject = (ProjectInfo) selectedItem;
selectProjectInfo(currentSelectedProject);
Logger.INSTANCE.insertDebug("", "Selected project: " + currentSelectedProject.fileName);
}
if (selectedItem instanceof Image) {
currentSelectedImage = (Image) selectedItem;
currentSelectedProject = getProjectForImage(currentSelectedImage);
selectImage(currentSelectedImage);
Logger.INSTANCE.insertDebug("", "Selected image: " + currentSelectedImage.getName() + " of project " + currentSelectedProject.fileName);
}
if (selectedItem instanceof GpsLog) {
currentSelectedGpsLog = (GpsLog) selectedItem;
currentSelectedProject = getProjectForGpsLog(currentSelectedGpsLog);
selectGpsLog(currentSelectedGpsLog);
Logger.INSTANCE.insertDebug("", "Selected gpslog: " + currentSelectedGpsLog.text + " of project " + currentSelectedProject.fileName);
}
if (selectedItem instanceof Note) {
currentSelectedNote = (Note) selectedItem;
currentSelectedProject = getProjectForNote(currentSelectedNote);
selectNote(currentSelectedNote);
Logger.INSTANCE.insertDebug("", "Selected note: " + currentSelectedNote.simpleText + " of project " + currentSelectedProject.fileName);
}
}
}
});
_databaseTree.setVisible(false);
} catch (Exception e1) {
Logger.INSTANCE.insertError("", "Error", e1);
}
layoutTree(null, false);
Component wwjPanelComponent = null;
try {
wwjPanelComponent = NwwPanel.createNwwPanel(true);
} catch (UnsatisfiedLinkError e1) {
// ignore
}
if (wwjPanelComponent instanceof NwwPanel) {
_nwwHolder.setLayout(new BorderLayout());
_nwwHolder.add(wwjPanelComponent, BorderLayout.CENTER);
wwjPanel = (NwwPanel) wwjPanelComponent;
wwjPanel.addOsmLayer();
geopapDataLayer = new RenderableLayer();
wwjPanel.addLayer(geopapDataLayer);
} else {
_nwwHolderFrame.setVisible(false);
_chartHolderFrame.setVisible(false);
setPreferredSize(new Dimension(400, 600));
}
}
use of com.google.cloud.vision.v1p3beta1.Image in project hortonmachine by TheHortonMachine.
the class OmsGeopaparazzi4Converter method media2FeatureCollection.
public static SimpleFeatureCollection media2FeatureCollection(IHMConnection connection, File mediaFolderFile, IHMProgressMonitor pm) throws Exception, IOException, FileNotFoundException {
DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
try {
GeometryFactory gf = GeometryUtilities.gf();
/*
* create the points shapefile
*/
newCollection = new DefaultFeatureCollection();
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("geopaparazzimediapoints");
b.setCRS(DefaultGeographicCRS.WGS84);
b.add("the_geom", Point.class);
String altimFN = ImageTableFields.COLUMN_ALTIM.getFieldName();
String tsFN = ImageTableFields.COLUMN_TS.getFieldName();
String azimFN = ImageTableFields.COLUMN_AZIM.getFieldName();
String imageNameFN = ImageTableFields.COLUMN_TEXT.getFieldName();
b.add(altimFN, String.class);
b.add(tsFN, String.class);
b.add(azimFN, Double.class);
b.add(imageNameFN, String.class);
SimpleFeatureType featureType = b.buildFeatureType();
List<Image> imagesList = DaoImages.getImagesList(connection);
pm.beginTask("Importing media...", imagesList.size());
for (Image image : imagesList) {
File newImageFile = new File(mediaFolderFile, image.getName());
byte[] imageData = DaoImages.getImageData(connection, image.getImageDataId());
try (OutputStream outStream = new FileOutputStream(newImageFile)) {
outStream.write(imageData);
}
Point point = gf.createPoint(new Coordinate(image.getLon(), image.getLat()));
long ts = image.getTs();
String dateTimeString = ETimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.format(new Date(ts));
String imageRelativePath = mediaFolderFile.getName() + "/" + image.getName();
Object[] values = new Object[] { point, image.getAltim(), dateTimeString, image.getAzim(), imageRelativePath };
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
builder.addAll(values);
SimpleFeature feature = builder.buildFeature(null);
newCollection.add(feature);
pm.worked(1);
}
} finally {
pm.done();
}
return newCollection;
}
use of com.google.cloud.vision.v1p3beta1.Image in project hortonmachine by TheHortonMachine.
the class OmsGeopaparazzi4Converter method media2IdBasedFeatureCollection.
public static SimpleFeatureCollection media2IdBasedFeatureCollection(IHMConnection connection, IHMProgressMonitor pm) throws Exception, IOException, FileNotFoundException {
try {
GeometryFactory gf = GeometryUtilities.gf();
/*
* create the points fc
*/
DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
SimpleFeatureType featureType = GeopaparazziUtilities.getMediaFeaturetype();
List<Image> imagesList = DaoImages.getImagesList(connection);
pm.beginTask("Importing media...", imagesList.size());
for (Image image : imagesList) {
Point point = gf.createPoint(new Coordinate(image.getLon(), image.getLat()));
long ts = image.getTs();
String dateTimeString = ETimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.format(new Date(ts));
Object[] values = new Object[] { point, image.getAltim(), dateTimeString, image.getAzim(), image.getImageDataId() };
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
builder.addAll(values);
SimpleFeature feature = builder.buildFeature(null);
newCollection.add(feature);
pm.worked(1);
}
return newCollection;
} finally {
pm.done();
}
}
use of com.google.cloud.vision.v1p3beta1.Image in project openj9 by eclipse-openj9.
the class XMLIndexReader method setJ9DumpData.
public void setJ9DumpData(long environ, String osType, String osSubType, String cpuType, int cpuCount, long bytesMem, int pointerSize, Image[] imageRef, ImageAddressSpace[] addressSpaceRef, ImageProcess[] processRef) {
Builder builder = null;
if (_stream == null) {
// extract directly from the file
builder = new Builder(_coreFile, _reader, environ, _fileResolvingAgent);
} else {
// extract using the data stream
builder = new Builder(_coreFile, _stream, environ, _fileResolvingAgent);
}
_coreFile.extract(builder);
// Jazz 4961 : chamlain : NumberFormatException opening corrupt dump
if (cpuType == null)
cpuType = builder.getCPUType();
String cpuSubType = builder.getCPUSubType();
if (osType == null)
osType = builder.getOSType();
long creationTime = builder.getCreationTime();
_coreImage = new Image(osType, osSubType, cpuType, cpuSubType, cpuCount, bytesMem, creationTime);
ImageAddressSpace addressSpace = (ImageAddressSpace) builder.getAddressSpaces().next();
ImageProcess process = (ImageProcess) addressSpace.getCurrentProcess();
// If not sure, use the first address space/process pair found
for (Iterator it = builder.getAddressSpaces(); it.hasNext(); ) {
ImageAddressSpace addressSpace1 = (ImageAddressSpace) it.next();
final boolean vb = false;
if (vb)
System.out.println("address space " + addressSpace1);
_coreImage.addAddressSpace(addressSpace1);
for (Iterator it2 = addressSpace1.getProcesses(); it2.hasNext(); ) {
ImageProcess process1 = (ImageProcess) it2.next();
if (vb)
try {
System.out.println("process " + process1.getID());
} catch (DataUnavailable e) {
} catch (CorruptDataException e) {
}
if (process == null || isProcessForEnvironment(environ, addressSpace1, process1)) {
addressSpace = addressSpace1;
process = process1;
if (vb)
System.out.println("default process for Runtime");
}
}
}
if (null != process) {
// z/OS can have 64-bit or 31-bit processes, Java only reports 64-bit or 32-bit.
if (process.getPointerSize() != pointerSize && !(process.getPointerSize() == 31 && pointerSize == 32)) {
System.out.println("XML and core file pointer sizes differ " + process.getPointerSize() + "!=" + pointerSize);
}
} else {
throw new IllegalStateException("No process found in the dump.");
}
imageRef[0] = _coreImage;
addressSpaceRef[0] = addressSpace;
processRef[0] = process;
}
Aggregations